diff --git a/Example/E01_gpio_demo/libraries/doc/version.txt b/Example/E01_gpio_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E01_gpio_demo/libraries/doc/version.txt
+++ b/Example/E01_gpio_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E01_gpio_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E01_gpio_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E01_gpio_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E01_gpio_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_clock.c b/Example/E01_gpio_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_clock.h b/Example/E01_gpio_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_debug.c b/Example/E01_gpio_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_debug.h b/Example/E01_gpio_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_fifo.c b/Example/E01_gpio_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_fifo.h b/Example/E01_gpio_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_font.c b/Example/E01_gpio_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_font.h b/Example/E01_gpio_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_function.c b/Example/E01_gpio_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_function.h b/Example/E01_gpio_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_headfile.h b/Example/E01_gpio_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E01_gpio_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E01_gpio_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_common/zf_common_typedef.h b/Example/E01_gpio_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E01_gpio_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E01_gpio_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_camera.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_camera.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_config.a b/Example/E01_gpio_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E01_gpio_demo/libraries/zf_device/zf_device_config.a and b/Example/E01_gpio_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_config.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_detector.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_detector.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips114.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips114.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips200.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips200.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_key.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_key.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_oled.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_oled.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_tft180.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_tft180.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_type.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_type.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E01_gpio_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E01_gpio_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E01_gpio_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E01_gpio_demo/user/isr.c b/Example/E01_gpio_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E01_gpio_demo/user/isr.c
+++ b/Example/E01_gpio_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E02_uart_demo/libraries/doc/version.txt b/Example/E02_uart_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E02_uart_demo/libraries/doc/version.txt
+++ b/Example/E02_uart_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E02_uart_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E02_uart_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E02_uart_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E02_uart_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_clock.c b/Example/E02_uart_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_clock.h b/Example/E02_uart_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_debug.c b/Example/E02_uart_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_debug.h b/Example/E02_uart_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_fifo.c b/Example/E02_uart_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_fifo.h b/Example/E02_uart_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_font.c b/Example/E02_uart_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_font.h b/Example/E02_uart_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_function.c b/Example/E02_uart_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_function.h b/Example/E02_uart_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_headfile.h b/Example/E02_uart_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E02_uart_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E02_uart_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_common/zf_common_typedef.h b/Example/E02_uart_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E02_uart_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E02_uart_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_camera.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_camera.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_config.a b/Example/E02_uart_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E02_uart_demo/libraries/zf_device/zf_device_config.a and b/Example/E02_uart_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_config.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_detector.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_detector.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_ips114.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_ips114.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_ips200.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_ips200.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_key.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_key.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_oled.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_oled.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_tft180.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_tft180.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_type.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_type.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E02_uart_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E02_uart_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E02_uart_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E02_uart_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E02_uart_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E02_uart_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E02_uart_demo/user/isr.c b/Example/E02_uart_demo/user/isr.c
index 1137b90..5651115 100644
--- a/Example/E02_uart_demo/user/isr.c
+++ b/Example/E02_uart_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E03_adc_demo/libraries/doc/version.txt b/Example/E03_adc_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E03_adc_demo/libraries/doc/version.txt
+++ b/Example/E03_adc_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E03_adc_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E03_adc_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E03_adc_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E03_adc_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_clock.c b/Example/E03_adc_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_clock.h b/Example/E03_adc_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_debug.c b/Example/E03_adc_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_debug.h b/Example/E03_adc_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_fifo.c b/Example/E03_adc_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_fifo.h b/Example/E03_adc_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_font.c b/Example/E03_adc_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_font.h b/Example/E03_adc_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_function.c b/Example/E03_adc_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_function.h b/Example/E03_adc_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_headfile.h b/Example/E03_adc_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E03_adc_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E03_adc_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_common/zf_common_typedef.h b/Example/E03_adc_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E03_adc_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E03_adc_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_camera.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_camera.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_config.a b/Example/E03_adc_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E03_adc_demo/libraries/zf_device/zf_device_config.a and b/Example/E03_adc_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_config.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_detector.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_detector.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_ips114.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_ips114.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_ips200.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_ips200.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_key.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_key.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_oled.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_oled.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_tft180.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_tft180.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_type.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_type.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E03_adc_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E03_adc_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E03_adc_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E03_adc_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E03_adc_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E03_adc_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E03_adc_demo/user/isr.c b/Example/E03_adc_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E03_adc_demo/user/isr.c
+++ b/Example/E03_adc_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E04_pwm_demo/libraries/doc/version.txt b/Example/E04_pwm_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E04_pwm_demo/libraries/doc/version.txt
+++ b/Example/E04_pwm_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E04_pwm_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E04_pwm_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E04_pwm_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E04_pwm_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_clock.c b/Example/E04_pwm_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_clock.h b/Example/E04_pwm_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_debug.c b/Example/E04_pwm_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_debug.h b/Example/E04_pwm_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_fifo.c b/Example/E04_pwm_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_fifo.h b/Example/E04_pwm_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_font.c b/Example/E04_pwm_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_font.h b/Example/E04_pwm_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_function.c b/Example/E04_pwm_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_function.h b/Example/E04_pwm_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_headfile.h b/Example/E04_pwm_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E04_pwm_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E04_pwm_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_common/zf_common_typedef.h b/Example/E04_pwm_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E04_pwm_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E04_pwm_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_camera.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_camera.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_config.a b/Example/E04_pwm_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E04_pwm_demo/libraries/zf_device/zf_device_config.a and b/Example/E04_pwm_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_config.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_detector.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_detector.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips114.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips114.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips200.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips200.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_key.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_key.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_oled.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_oled.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_tft180.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_tft180.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_type.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_type.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E04_pwm_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E04_pwm_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E04_pwm_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E04_pwm_demo/user/isr.c b/Example/E04_pwm_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E04_pwm_demo/user/isr.c
+++ b/Example/E04_pwm_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E05_pit_demo/libraries/doc/version.txt b/Example/E05_pit_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E05_pit_demo/libraries/doc/version.txt
+++ b/Example/E05_pit_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E05_pit_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E05_pit_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E05_pit_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E05_pit_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_clock.c b/Example/E05_pit_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_clock.h b/Example/E05_pit_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_debug.c b/Example/E05_pit_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_debug.h b/Example/E05_pit_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_fifo.c b/Example/E05_pit_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_fifo.h b/Example/E05_pit_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_font.c b/Example/E05_pit_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_font.h b/Example/E05_pit_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_function.c b/Example/E05_pit_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_function.h b/Example/E05_pit_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_headfile.h b/Example/E05_pit_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E05_pit_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E05_pit_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_common/zf_common_typedef.h b/Example/E05_pit_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E05_pit_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E05_pit_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_camera.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_camera.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_config.a b/Example/E05_pit_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E05_pit_demo/libraries/zf_device/zf_device_config.a and b/Example/E05_pit_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_config.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_detector.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_detector.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_ips114.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_ips114.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_ips200.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_ips200.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_key.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_key.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_oled.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_oled.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_tft180.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_tft180.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_type.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_type.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E05_pit_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E05_pit_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E05_pit_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E05_pit_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E05_pit_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E05_pit_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E05_pit_demo/user/isr.c b/Example/E05_pit_demo/user/isr.c
index 79b7581..6ecd4f9 100644
--- a/Example/E05_pit_demo/user/isr.c
+++ b/Example/E05_pit_demo/user/isr.c
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E06_exit_demo/libraries/doc/version.txt b/Example/E06_exit_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E06_exit_demo/libraries/doc/version.txt
+++ b/Example/E06_exit_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E06_exit_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E06_exit_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E06_exit_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E06_exit_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_clock.c b/Example/E06_exit_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_clock.h b/Example/E06_exit_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_debug.c b/Example/E06_exit_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_debug.h b/Example/E06_exit_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_fifo.c b/Example/E06_exit_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_fifo.h b/Example/E06_exit_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_font.c b/Example/E06_exit_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_font.h b/Example/E06_exit_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_function.c b/Example/E06_exit_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_function.h b/Example/E06_exit_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_headfile.h b/Example/E06_exit_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E06_exit_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E06_exit_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_common/zf_common_typedef.h b/Example/E06_exit_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E06_exit_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E06_exit_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_camera.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_camera.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_config.a b/Example/E06_exit_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E06_exit_demo/libraries/zf_device/zf_device_config.a and b/Example/E06_exit_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_config.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_detector.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_detector.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_ips114.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_ips114.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_ips200.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_ips200.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_key.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_key.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_oled.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_oled.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_tft180.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_tft180.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_type.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_type.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E06_exit_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E06_exit_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E06_exit_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E06_exit_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E06_exit_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E06_exit_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E06_exit_demo/user/isr.c b/Example/E06_exit_demo/user/isr.c
index a6b5781..b7ec3ef 100644
--- a/Example/E06_exit_demo/user/isr.c
+++ b/Example/E06_exit_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(cc61_pit_ch1_isr, 0, CCU6_1_CH1_ISR_PRIORITY)
//IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
//{
// interrupt_global_enable(0); // 开启中断嵌套
+//
// if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
// {
// exti_flag_clear(ERU_CH1_REQ10_P14_3);
//
-//
+// tof_module_exti_handler(); // ToF 模块 INT 更新中断
//
// }
//
@@ -113,6 +114,7 @@ IFX_INTERRUPT(cc61_pit_ch1_isr, 0, CCU6_1_CH1_ISR_PRIORITY)
// {
// exti_flag_clear(ERU_CH5_REQ1_P15_8);
//
+// wireless_module_spi_handler(); // SPI WIFI 中断回调函数
//
// }
//}
diff --git a/Example/E07_encoder_demo/libraries/doc/version.txt b/Example/E07_encoder_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E07_encoder_demo/libraries/doc/version.txt
+++ b/Example/E07_encoder_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E07_encoder_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E07_encoder_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E07_encoder_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E07_encoder_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_clock.c b/Example/E07_encoder_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_clock.h b/Example/E07_encoder_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_debug.c b/Example/E07_encoder_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_debug.h b/Example/E07_encoder_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_fifo.c b/Example/E07_encoder_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_fifo.h b/Example/E07_encoder_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_font.c b/Example/E07_encoder_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_font.h b/Example/E07_encoder_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_function.c b/Example/E07_encoder_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_function.h b/Example/E07_encoder_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_headfile.h b/Example/E07_encoder_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E07_encoder_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E07_encoder_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_common/zf_common_typedef.h b/Example/E07_encoder_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E07_encoder_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E07_encoder_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_camera.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_camera.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_config.a b/Example/E07_encoder_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E07_encoder_demo/libraries/zf_device/zf_device_config.a and b/Example/E07_encoder_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_config.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_detector.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_detector.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips114.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips114.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips200.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips200.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_key.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_key.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_oled.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_oled.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_tft180.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_tft180.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_type.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_type.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E07_encoder_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E07_encoder_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E07_encoder_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E07_encoder_demo/user/isr.c b/Example/E07_encoder_demo/user/isr.c
index 79b7581..6ecd4f9 100644
--- a/Example/E07_encoder_demo/user/isr.c
+++ b/Example/E07_encoder_demo/user/isr.c
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E08_eeprom_demo/libraries/doc/version.txt b/Example/E08_eeprom_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E08_eeprom_demo/libraries/doc/version.txt
+++ b/Example/E08_eeprom_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E08_eeprom_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E08_eeprom_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E08_eeprom_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E08_eeprom_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_clock.c b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_clock.h b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_debug.c b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_debug.h b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_fifo.c b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_fifo.h b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_font.c b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_font.h b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_function.c b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_function.h b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_headfile.h b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_typedef.h b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E08_eeprom_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E08_eeprom_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_camera.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_camera.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_config.a b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_config.a and b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_config.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_detector.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_detector.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips114.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips114.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips200.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips200.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_key.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_key.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_oled.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_oled.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tft180.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tft180.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_type.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_type.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E08_eeprom_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E08_eeprom_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E08_eeprom_demo/user/isr.c b/Example/E08_eeprom_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E08_eeprom_demo/user/isr.c
+++ b/Example/E08_eeprom_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E09_timer_demo/libraries/doc/version.txt b/Example/E09_timer_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E09_timer_demo/libraries/doc/version.txt
+++ b/Example/E09_timer_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E09_timer_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E09_timer_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E09_timer_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E09_timer_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_clock.c b/Example/E09_timer_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_clock.h b/Example/E09_timer_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_debug.c b/Example/E09_timer_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_debug.h b/Example/E09_timer_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_fifo.c b/Example/E09_timer_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_fifo.h b/Example/E09_timer_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_font.c b/Example/E09_timer_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_font.h b/Example/E09_timer_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_function.c b/Example/E09_timer_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_function.h b/Example/E09_timer_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_headfile.h b/Example/E09_timer_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E09_timer_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E09_timer_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_common/zf_common_typedef.h b/Example/E09_timer_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E09_timer_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E09_timer_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_camera.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_camera.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_config.a b/Example/E09_timer_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E09_timer_demo/libraries/zf_device/zf_device_config.a and b/Example/E09_timer_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_config.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_detector.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_detector.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_ips114.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_ips114.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_ips200.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_ips200.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_key.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_key.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_oled.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_oled.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_tft180.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_tft180.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_type.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_type.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E09_timer_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E09_timer_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E09_timer_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E09_timer_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E09_timer_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E09_timer_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E09_timer_demo/user/isr.c b/Example/E09_timer_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E09_timer_demo/user/isr.c
+++ b/Example/E09_timer_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E10_printf_debug_log_demo/libraries/doc/version.txt b/Example/E10_printf_debug_log_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E10_printf_debug_log_demo/libraries/doc/version.txt
+++ b/Example/E10_printf_debug_log_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E10_printf_debug_log_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E10_printf_debug_log_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E10_printf_debug_log_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E10_printf_debug_log_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_clock.c b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_clock.h b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_debug.c b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_debug.h b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_fifo.c b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_fifo.h b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_font.c b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_font.h b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_function.c b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_function.h b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_headfile.h b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_typedef.h b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_camera.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_camera.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_config.a b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_config.a and b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_config.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_detector.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_detector.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips114.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips114.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips200.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips200.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_key.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_key.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_oled.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_oled.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tft180.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tft180.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_type.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_type.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E10_printf_debug_log_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E10_printf_debug_log_demo/user/cpu0_main.c b/Example/E10_printf_debug_log_demo/user/cpu0_main.c
index a6685b3..23560ce 100644
--- a/Example/E10_printf_debug_log_demo/user/cpu0_main.c
+++ b/Example/E10_printf_debug_log_demo/user/cpu0_main.c
@@ -107,7 +107,7 @@ int core0_main(void)
printf("Time: %d s.\r\n", assert_count / 1000); // printf 使用方法不作介绍
}
#if DEBUG_UART_USE_INTERRUPT // 如果开启了 debug uart 接收中断
- debug_uart_data_len = (uint8)debug_read_ring_buffer(debug_uart_data_buffer); // 获取数据
+ debug_uart_data_len = (uint8)debug_read_ring_buffer(debug_uart_data_buffer, sizeof(debug_uart_data_buffer)); // 获取数据
if(debug_uart_data_len != 0) // 判断是否收到 debug uart 数据
{
printf("\r\n"); // 输出换行
diff --git a/Example/E10_printf_debug_log_demo/user/isr.c b/Example/E10_printf_debug_log_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E10_printf_debug_log_demo/user/isr.c
+++ b/Example/E10_printf_debug_log_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/doc/version.txt b/Example/E11_interrupt_priority_set_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/doc/version.txt
+++ b/Example/E11_interrupt_priority_set_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E11_interrupt_priority_set_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_clock.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_clock.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_debug.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_debug.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_fifo.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_fifo.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_font.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_font.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_function.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_function.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_headfile.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_typedef.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_camera.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_camera.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_config.a b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_config.a and b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_config.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_detector.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_detector.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips114.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips114.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips200.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips200.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_key.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_key.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_oled.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_oled.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tft180.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tft180.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_type.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_type.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E11_interrupt_priority_set_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E11_interrupt_priority_set_demo/user/isr.c b/Example/E11_interrupt_priority_set_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E11_interrupt_priority_set_demo/user/isr.c
+++ b/Example/E11_interrupt_priority_set_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/doc/version.txt b/Example/E12_cpu1_handles_interrupts_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/doc/version.txt
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_clock.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_clock.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_debug.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_debug.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_fifo.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_fifo.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_font.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_font.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_function.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_function.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_headfile.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_typedef.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_camera.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_camera.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_config.a b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_config.a and b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_config.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_detector.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_detector.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips114.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips114.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips200.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips200.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_key.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_key.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_oled.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_oled.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tft180.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tft180.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_type.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_type.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E12_cpu1_handles_interrupts_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E12_cpu1_handles_interrupts_demo/user/isr.c b/Example/E12_cpu1_handles_interrupts_demo/user/isr.c
index 79b7581..6ecd4f9 100644
--- a/Example/E12_cpu1_handles_interrupts_demo/user/isr.c
+++ b/Example/E12_cpu1_handles_interrupts_demo/user/isr.c
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E13_dual_core_demo/libraries/doc/version.txt b/Example/E13_dual_core_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E13_dual_core_demo/libraries/doc/version.txt
+++ b/Example/E13_dual_core_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E13_dual_core_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E13_dual_core_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E13_dual_core_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E13_dual_core_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_clock.c b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_clock.h b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_debug.c b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_debug.h b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_fifo.c b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_fifo.h b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_font.c b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_font.h b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_function.c b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_function.h b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_headfile.h b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_typedef.h b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E13_dual_core_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E13_dual_core_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_camera.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_camera.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_config.a b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_config.a and b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_config.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_detector.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_detector.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips114.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips114.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips200.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips200.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_key.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_key.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_oled.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_oled.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tft180.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tft180.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_type.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_type.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E13_dual_core_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E13_dual_core_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E13_dual_core_demo/user/isr.c b/Example/E13_dual_core_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E13_dual_core_demo/user/isr.c
+++ b/Example/E13_dual_core_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/doc/version.txt b/Example/E14_specifies_variable_or_code_location_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/doc/version.txt
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_clock.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_clock.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_debug.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_debug.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_fifo.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_fifo.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_font.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_font.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_function.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_function.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_headfile.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_typedef.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_camera.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_camera.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_config.a b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_config.a and b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_config.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_detector.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_detector.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips114.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips114.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips200.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips200.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_key.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_key.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_oled.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_oled.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tft180.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tft180.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_type.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_type.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E14_specifies_variable_or_code_location_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E14_specifies_variable_or_code_location_demo/user/isr.c b/Example/E14_specifies_variable_or_code_location_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E14_specifies_variable_or_code_location_demo/user/isr.c
+++ b/Example/E14_specifies_variable_or_code_location_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Example/E15_fft_demo/libraries/doc/version.txt b/Example/E15_fft_demo/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Example/E15_fft_demo/libraries/doc/version.txt
+++ b/Example/E15_fft_demo/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Example/E15_fft_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Example/E15_fft_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Example/E15_fft_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Example/E15_fft_demo/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_clock.c b/Example/E15_fft_demo/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_clock.c
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_clock.h b/Example/E15_fft_demo/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_clock.h
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_debug.c b/Example/E15_fft_demo/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_debug.c
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_debug.h b/Example/E15_fft_demo/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_debug.h
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_fifo.c b/Example/E15_fft_demo/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_fifo.c
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_fifo.h b/Example/E15_fft_demo/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_fifo.h
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_font.c b/Example/E15_fft_demo/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_font.c
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_font.h b/Example/E15_fft_demo/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_font.h
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_function.c b/Example/E15_fft_demo/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_function.c
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_function.h b/Example/E15_fft_demo/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_function.h
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_headfile.h b/Example/E15_fft_demo/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_headfile.h
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_interrupt.c b/Example/E15_fft_demo/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_interrupt.c
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_interrupt.h b/Example/E15_fft_demo/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_interrupt.h
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_common/zf_common_typedef.h b/Example/E15_fft_demo/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Example/E15_fft_demo/libraries/zf_common/zf_common_typedef.h
+++ b/Example/E15_fft_demo/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_absolute_encoder.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_absolute_encoder.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_camera.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_camera.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_camera.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_camera.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_config.a b/Example/E15_fft_demo/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Example/E15_fft_demo/libraries/zf_device/zf_device_config.a and b/Example/E15_fft_demo/libraries/zf_device/zf_device_config.a differ
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_config.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_config.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_detector.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_detector.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1a.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1a.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1a.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1a.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1b.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1b.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_gps_tau1201.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_gps_tau1201.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_icm20602.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_icm20602.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_icm20602.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_icm20602.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_imu660ra.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_imu660ra.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_imu660ra.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_imu660ra.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_imu963ra.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_imu963ra.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_imu963ra.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_imu963ra.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_ips114.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_ips114.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_ips114.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_ips114.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_ips200.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_ips200.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_ips200.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_ips200.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_key.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_key.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_key.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_key.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_mpu6050.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_mpu6050.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_mpu6050.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_mpu6050.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_mt9v03x.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_mt9v03x.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_oled.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_oled.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_oled.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_oled.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_ov7725.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_ov7725.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_ov7725.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_ov7725.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_scc8660.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_scc8660.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_scc8660.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_scc8660.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_tft180.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_tft180.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_tft180.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_tft180.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_tsl1401.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_tsl1401.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_tsl1401.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_tsl1401.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_type.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_type.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_type.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_type.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_spi.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_spi.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_uart.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_uart.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_wireless_uart.c b/Example/E15_fft_demo/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_device/zf_device_wireless_uart.h b/Example/E15_fft_demo/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Example/E15_fft_demo/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Example/E15_fft_demo/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_adc.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_adc.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_adc.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_adc.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_delay.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_delay.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_delay.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_delay.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_dma.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_dma.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_dma.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_dma.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_encoder.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_encoder.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_encoder.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_encoder.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_exti.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_exti.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_exti.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_exti.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_flash.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_flash.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_flash.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_flash.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_gpio.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_gpio.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_gpio.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_gpio.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pit.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pit.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pit.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pit.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pwm.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pwm.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pwm.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pwm.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_iic.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_iic.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_spi.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_spi.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_spi.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_spi.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_spi.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_spi.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_timer.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_timer.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_timer.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_timer.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_uart.c b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_uart.c
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_uart.h b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Example/E15_fft_demo/libraries/zf_driver/zf_driver_uart.h
+++ b/Example/E15_fft_demo/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Example/E15_fft_demo/user/isr.c b/Example/E15_fft_demo/user/isr.c
index be4734c..79aaf22 100644
--- a/Example/E15_fft_demo/user/isr.c
+++ b/Example/E15_fft_demo/user/isr.c
@@ -42,7 +42,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
interrupt_global_enable(0); // 开启中断嵌套
pit_clear_flag(CCU60_CH0);
-
+
}
@@ -101,11 +101,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +114,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Seekfree_TC264_Opensource_Library/.cproject b/Seekfree_TC264_Opensource_Library/.cproject
index 48a3079..4949865 100644
--- a/Seekfree_TC264_Opensource_Library/.cproject
+++ b/Seekfree_TC264_Opensource_Library/.cproject
@@ -12,7 +12,7 @@
-
+
@@ -181,6 +181,12 @@
+
@@ -189,6 +195,14 @@
+
+
+ /Libraries/iLLD/TC26B/Tricore/Cpu/Trap
+ /Configurations/Debug
+ /Libraries/iLLD/TC26B/Tricore/Cpu/CStart
+ /Configurations
+
+
@@ -201,7 +215,7 @@
-
+
@@ -210,282 +224,282 @@
+
+
+ /Libraries/iLLD/TC26B/Tricore/Cpu/Trap
+ /Configurations/Debug
+ /Libraries/iLLD/TC26B/Tricore/Cpu/CStart
+ /Configurations
+
+
@@ -517,7 +539,7 @@
-
+
@@ -526,144 +548,144 @@
@@ -671,144 +693,144 @@
@@ -827,6 +849,14 @@
+
+
+ /Libraries/iLLD/TC26B/Tricore/Cpu/Trap
+ /Configurations/Debug
+ /Libraries/iLLD/TC26B/Tricore/Cpu/CStart
+ /Configurations
+
+
@@ -841,7 +871,7 @@
-
+
@@ -850,144 +880,144 @@
@@ -995,144 +1025,144 @@
@@ -1151,6 +1181,14 @@
+
+
+ /Libraries/iLLD/TC26B/Tricore/Cpu/Trap
+ /Configurations/Debug
+ /Libraries/iLLD/TC26B/Tricore/Cpu/CStart
+ /Configurations
+
+
diff --git a/Seekfree_TC264_Opensource_Library/libraries/doc/version.txt b/Seekfree_TC264_Opensource_Library/libraries/doc/version.txt
index 832eba9..846ad0c 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/doc/version.txt
+++ b/Seekfree_TC264_Opensource_Library/libraries/doc/version.txt
@@ -1,3 +1,10 @@
+V3.2.0
+ 新增wifi spi模块驱动文件
+ 新增detector上位机API接口
+ 新增四类总线报错提醒,并添加断言保护
+ zf_device_type 新增 ToF 类别控制
+ 新增 ToF 模块 DL1B
+ 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
V3.1.9
修复单片机可能启动失败的问题
修复核心板ESR1引脚可能触发复位的问题
diff --git a/Seekfree_TC264_Opensource_Library/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c b/Seekfree_TC264_Opensource_Library/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
index 02c7cb5..5af2ba4 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/infineon_libraries/iLLD/TC26B/Tricore/Cpu/Trap/IfxCpu_Trap.c
@@ -133,6 +133,8 @@ void IfxCpu_Trap_memoryManagementError(uint32 tin)
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_memoryManagement, tin);
IFX_CFG_CPU_TRAP_MME_HOOK(trapWatch);
+ // 如果单片机卡死在这里,则说明出现了内存管理报错,报错原因需自行排查
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -158,6 +160,9 @@ void IfxCpu_Trap_instructionError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_instructionErrors, tin);
IFX_CFG_CPU_TRAP_IE_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明执行了错误的指令,具体原因通过debug查找
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -169,6 +174,9 @@ void IfxCpu_Trap_contextManagementError(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_contextManagement, tin);
IFX_CFG_CPU_TRAP_CME_HOOK(trapWatch);
+
+ // 单片机调度管理错误,一般不会触发此类报错,如若触发则自行debug查找问题
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
@@ -196,6 +204,9 @@ void IfxCpu_Trap_assertion(uint32 tin)
volatile IfxCpu_Trap trapWatch;
trapWatch = IfxCpu_Trap_extractTrapInfo(IfxCpu_Trap_Class_assertion, tin);
IFX_CFG_CPU_TRAP_ASSERT_HOOK(trapWatch);
+
+ // 如果单片机卡死在这里,则说明触发了英飞凌的断言,通过调试来查看具体触发断言的位置并修正
+
IFX_CFG_CPU_TRAP_DEBUG;
__asm("rslcx"); /* Restore lower context before returning. lower context was stored in the trap vector */
__asm("rfe");
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_clock.c b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_clock.c
index 6e68809..081e2f3 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_clock.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_clock.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_clock.h b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_clock.h
index 47cfde1..9face65 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_clock.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_clock.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_debug.c b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_debug.c
index 3c0ea6f..ea153a2 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_debug.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_debug.c
@@ -24,13 +24,14 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
@@ -205,20 +206,34 @@ static void debug_output (char *type, char *file, int line, char *str)
}
}
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 调试串口发送缓冲区
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要发送的长度
+// 返回参数 uint32 剩余未发送的长度
+// 使用示例
+// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
+//-------------------------------------------------------------------------------------------------------------------
+uint32 debug_send_buffer(const uint8 *buff, uint32 len)
+{
+ uart_write_buffer(DEBUG_UART_INDEX, buff, len);
+ return 0;
+}
+
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 读取 debug 环形缓冲区数据
-// 参数说明 *data 读出数据存放的数组指针
+// 参数说明 *buff 读出数据存放的数组指针
+// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
-// 使用示例 uint8 data[64]; uint32 len = debug_read_ring_buffer(data);
+// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
-uint32 debug_read_ring_buffer (uint8 *data)
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
- uint32 data_len = sizeof(data);
- fifo_read_buffer(&debug_uart_fifo, data, &data_len, FIFO_READ_AND_CLEAN);
- return data_len;
+ fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
+ return len;
}
//-------------------------------------------------------------------------------------------------------------------
@@ -243,10 +258,10 @@ void debug_interrupr_handler (void)
//------------------------------------------------------------------------- // printf 重定向 此部分不允许用户更改
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fputc(int ch, FILE *stream)
{
@@ -254,10 +269,10 @@ int fputc(int ch, FILE *stream)
return(ch);
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 重定向printf 到串口
-// @param ch 需要打印的字节
-// @param stream 数据流
-// @note 此函数由编译器自带库里的printf所调用
+// 函数简介 重定向printf 到串口
+// 参数说明 ch 需要打印的字节
+// 参数说明 stream 数据流
+// 备注信息 此函数由编译器自带库里的printf所调用
//-------------------------------------------------------------------------------------------------------------------
int fgetc(FILE *f)
{
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_debug.h b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_debug.h
index d235093..881a297 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_debug.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_debug.h
@@ -24,25 +24,28 @@
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-05-26 pudding 新增调试串口发送函数,修改默认开启接收中断
+* 2022-05-27 pudding 新增四个总线报错接管,新增总线报错时关闭所有中断及PWM输出
********************************************************************************************************************/
#ifndef _zf_common_debug_h_
#define _zf_common_debug_h_
#include "zf_common_typedef.h"
+#include "zf_common_interrupt.h"
#define DEBUG_UART_INDEX (UART_0) // 指定 debug uart 所使用的的串口
#define DEBUG_UART_BAUDRATE (115200) // 指定 debug uart 所使用的的串口波特率
#define DEBUG_UART_TX_PIN (UART0_TX_P14_0) // 指定 debug uart 所使用的的串口引脚
#define DEBUG_UART_RX_PIN (UART0_RX_P14_1) // 指定 debug uart 所使用的的串口引脚
-#define DEBUG_UART_USE_INTERRUPT (0) // 是否启用 debug uart 接收中断
+#define DEBUG_UART_USE_INTERRUPT (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
@@ -72,8 +75,12 @@
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
-#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, please check"); while(1);
-#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, array access may be out of bounds, please check"); while(1);
+#define IFX_CFG_CPU_TRAP_BE_HOOK(x) zf_log(0, "Memory access failure or Use an uninitialized peripheral, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IPE_HOOK(x) zf_log(0, "Accessing an null address, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_ASSERT_HOOK(x) zf_log(0, "Cpu Assertion error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_CME_HOOK(x) zf_log(0, "Context management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_IE_HOOK(x) zf_log(0, "Instruction Error, Locate faults through debugging"); assert_interrupt_config(); while(1);
+#define IFX_CFG_CPU_TRAP_MME_HOOK(x) zf_log(0, "Memory management error, Locate faults through debugging"); assert_interrupt_config(); while(1);
typedef struct
@@ -86,26 +93,27 @@ typedef struct
uint8 font_x_size;
uint8 font_y_size;
- void (*output_uart) (const char *str);
- void (*output_screen) (uint16 x, uint16 y, const char *str);
- void (*output_screen_clear) (void);
+ void (*output_uart) (const char *str);
+ void (*output_screen) (uint16 x, uint16 y, const char *str);
+ void (*output_screen_clear) (void);
}debug_output_struct;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
-#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
-void debug_interrupr_handler (void);
-uint32 debug_read_ring_buffer (uint8 *data);
+#define DEBUG_RING_BUFFER_LEN (64) // 定义环形缓冲区大小 默认 64byte
+void debug_interrupr_handler (void);
+uint32 debug_read_ring_buffer (uint8 *buff, uint32 len);
#endif
-void debug_assert_enable (void);
-void debug_assert_disable (void);
-void debug_assert_handler (uint8 pass, char *file, int line);
-void debug_log_handler (uint8 pass, char *str, char *file, int line);
-void debug_output_struct_init (debug_output_struct *info);
-void debug_output_init (debug_output_struct *info);
-void debug_init (void);
+uint32 debug_send_buffer (const uint8 *buff, uint32 len); // 调试串口缓冲区发送
+void debug_assert_enable (void);
+void debug_assert_disable (void);
+void debug_assert_handler (uint8 pass, char *file, int line);
+void debug_log_handler (uint8 pass, char *str, char *file, int line);
+void debug_output_struct_init (debug_output_struct *info);
+void debug_output_init (debug_output_struct *info);
+void debug_init (void);
#endif
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_fifo.c b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_fifo.c
index 439a216..3689a2a 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_fifo.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_fifo.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -92,6 +92,7 @@ fifo_state_enum fifo_clear (fifo_struct *fifo)
fifo->head = 0;
fifo->end = 0;
fifo->size = fifo->max;
+
switch(fifo->type)
{
case FIFO_DATA_8BIT:
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_fifo.h b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_fifo.h
index 383f407..f28d7ac 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_fifo.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_fifo.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_font.c b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_font.c
index 9af2919..c816f9d 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_font.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_font.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_font.h b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_font.h
index 716e38f..24b8602 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_font.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_font.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_function.c b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_function.c
index a6b9009..d403fb5 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_function.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_function.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_function.h b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_function.h
index f83bd95..f5683e1 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_function.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_function.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_headfile.h b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_headfile.h
index 4e7194f..9e0b161 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_headfile.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_headfile.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -83,7 +83,9 @@
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gps_tau1201.h"
#include "zf_device_camera.h"
+#include "zf_device_detector.h"
#include "zf_device_dl1a.h"
+#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu963ra.h"
@@ -100,6 +102,7 @@
#include "zf_device_type.h"
#include "zf_device_virtual_oscilloscope.h"
#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
#include "zf_device_wireless_uart.h"
//===================================================外接设备驱动层===================================================
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_interrupt.c b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_interrupt.c
index d077268..61058b2 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_interrupt.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_interrupt.c
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -81,5 +81,4 @@ void assert_interrupt_config (void)
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
-
}
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_interrupt.h b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_interrupt.h
index 06bffc3..99b0e53 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_interrupt.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_interrupt.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_typedef.h b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_typedef.h
index 9e2897f..4a98083 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_typedef.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_common/zf_common_typedef.h
@@ -24,7 +24,7 @@
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_absolute_encoder.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_absolute_encoder.c
index 782e7ac..7c80a3b 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_absolute_encoder.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_absolute_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_absolute_encoder.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_absolute_encoder.h
index cc31af5..e6cc057 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_absolute_encoder.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_absolute_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_absolute_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_bluetooth_ch9141.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_bluetooth_ch9141.c
index b99aab5..af4562f 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_bluetooth_ch9141.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_bluetooth_ch9141.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_bluetooth_ch9141
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_bluetooth_ch9141.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_bluetooth_ch9141.h
index 9732284..800be6c 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_bluetooth_ch9141.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_bluetooth_ch9141.h
@@ -24,7 +24,7 @@
* 文件名称 main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_camera.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_camera.c
index fb9365d..69f947c 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_camera.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_camera.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,10 +50,10 @@ uint8 camera_receiver_buffer[CAMERA_RECEIVER_BUFFER_SIZE]; //
uint8 camera_send_image_frame_header[4] = {0x00, 0xFF, 0x01, 0x01}; // 定义摄像头数据发送到上位机的帧头
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
-// @param *data1 摄像头图像数组
-// @param *data2 存放解压数据的地址
-// @param image_size 图像的大小
+// 函数简介 摄像头二进制图像数据解压为十六进制八位数据 小钻风用
+// 参数说明 *data1 摄像头图像数组
+// 参数说明 *data2 存放解压数据的地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_binary_image_decompression(&ov7725_image_binary[0][0], &data_buffer[0][0], OV7725_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -75,10 +75,10 @@ void camera_binary_image_decompression (const uint8 *data1, uint8 *data2, uint32
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头图像发送至上位机查看图像
-// @param uartn 使用的串口号
-// @param *image_addr 需要发送的图像地址
-// @param image_size 图像的大小
+// 函数简介 摄像头图像发送至上位机查看图像
+// 参数说明 uartn 使用的串口号
+// 参数说明 *image_addr 需要发送的图像地址
+// 参数说明 image_size 图像的大小
// @return void
// Sample usage: camera_send_image(DEBUG_UART_INDEX, &mt9v03x_image[0][0], MT9V03X_IMAGE_SIZE);
//-------------------------------------------------------------------------------------------------------------------
@@ -106,12 +106,12 @@ void camera_fifo_init (void)
//-------------------------------------------------------------------------------------------------------------------
-// @brief 摄像头采集初始化
-// @param image_size 图像的大小
+// 函数简介 摄像头采集初始化
+// 参数说明 image_size 图像的大小
// @return void
-// @param image_size 图像的大小
-// @param data_addr 数据来源外设地址
-// @param buffer_addr 图像缓冲区地址
+// 参数说明 image_size 图像的大小
+// 参数说明 data_addr 数据来源外设地址
+// 参数说明 buffer_addr 图像缓冲区地址
// @return void
// Sample usage: camera_init();
//-------------------------------------------------------------------------------------------------------------------
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_camera.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_camera.h
index 826bb03..5cfd10f 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_camera.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_camera.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_camera
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_config.a b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_config.a
index f1eb0eb..6999daf 100644
Binary files a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_config.a and b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_config.a differ
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_config.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_config.h
index 7812a05..af6a3d8 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_config.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_config.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -36,10 +36,8 @@
#ifndef _zf_device_config_h_
#define _zf_device_config_h_
-
-
-
extern const unsigned char imu660ra_config_file[8192];
+extern const unsigned char dl1b_config_file[135];
unsigned char mt9v03x_set_config_sccb (void *soft_iic_obj, short int buff[10][2]);
unsigned char mt9v03x_set_exposure_time_sccb (unsigned short int light);
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_detector.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_detector.c
new file mode 100644
index 0000000..7a04b7b
--- /dev/null
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_detector.c
@@ -0,0 +1,628 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#include "zf_driver_uart.h"
+#include "zf_common_fifo.h"
+#include "zf_device_wireless_uart.h"
+#include "zf_device_bluetooth_ch9141.h"
+#include "zf_device_wifi_uart.h"
+#include "zf_device_wifi_spi.h"
+
+#include "zf_device_detector.h"
+
+
+typedef uint32 (*detector_transfer_callback_function) (const uint8 *buff, uint32 length);
+typedef uint32 (*detector_receive_callback_function) (uint8 *buff, uint32 length);
+
+detector_transfer_type_enum detector_transfer_type; // 数据传输方式
+
+detector_transfer_callback_function detector_transfer_callback; // 数据发送函数指针
+detector_receive_callback_function detector_receive_callback; // 数据接收函数指针
+
+detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+static detector_camera_struct detector_camera_data; // 图像上位机协议数据
+static detector_camera_dot_struct detector_camera_dot_data; // 图像上位机打点协议数据
+static detector_camera_buffer_struct detector_camera_buffer; // 图像以及边界缓冲区信息
+
+static fifo_struct detector_fifo;
+static uint8 detector_buffer[DETECTOR_BUFFER_SIZE]; // 数据存放数组
+float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口发送函数
+//// 参数说明 *buff 需要发送的数据地址
+//// 参数说明 length 需要发送的长度
+//// 返回参数 uint32 剩余未发送数据长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_transfer (const uint8 *buff, uint32 length)
+//{
+// uart_write_buffer(DEBUG_UART_INDEX, buff, length);
+// return 0;
+//}
+
+////-------------------------------------------------------------------------------------------------------------------
+//// 函数简介 滴答客有线串口接收函数
+//// 参数说明 *buff 需要接收的数据地址
+//// 参数说明 length 需要接收的长度
+//// 返回参数 uint32 实际接收长度
+//// 使用示例
+////-------------------------------------------------------------------------------------------------------------------
+//uint32 detector_debug_uart_receive (uint8 *buff, uint32 length)
+//{
+// return debug_read_ring_buffer(buff, length);
+//}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义字节发送函数
+// 参数说明 data 需要发送的数据地址
+// 返回参数 uint8
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_custom_write_byte(const uint8 data)
+{
+ // 自行实现字节发送
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义发送函数
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 如果数据传输方式并不在支持范围则可以自行实现
+//-------------------------------------------------------------------------------------------------------------------
+uint32 detector_custom_transfer (const uint8 *buff, uint32 length)
+{
+ uint32 send_length;
+ send_length = length;
+
+ while(send_length--)
+ {
+ detector_custom_write_byte(*buff);
+ buff++;
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按字节接收
+// 参数说明 *data 需要发送的数据地址
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive_byte (uint8 data)
+{
+ uint8 return_state = 0;
+ // 自行实现字节发送
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, &data, 1))
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客自定义接收函数 按数组接收
+// 参数说明 *buff 需要发送的数据地址
+// 参数说明 length 需要发送的长度
+// 返回参数 uint8 0:接收成功 1:接收失败
+// 注意事项 detector_custom_receive_byte 与 detector_custom_receive函数 只需要调用其中一个函数即可
+//-------------------------------------------------------------------------------------------------------------------
+uint8 detector_custom_receive (uint8 *buff, uint32 length)
+{
+ uint8 return_state = 0;
+
+ // 将接收到的数据写入FIFO
+ if(FIFO_SUCCESS != fifo_write_buffer(&detector_fifo, buff, length))
+ {
+ return_state = 1;
+ }
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送函数
+// 参数说明 *send_data 需要发送的数据地址
+// 参数说明 send_length 需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint32 detector_transfer (void *send_data, uint32 send_length)
+{
+ return detector_transfer_callback((const uint8 *)send_data, send_length);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客求和函数
+// 参数说明 *buffer 需要校验的数据地址
+// 参数说明 length 校验长度
+// 返回参数 uint8 和值
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+static uint8 detector_sum (uint8 *buffer, uint32 length)
+{
+ uint8 temp_sum = 0;
+
+ while(length--)
+ {
+ temp_sum += *buffer++;
+ }
+
+ return temp_sum;
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像发送函数
+// 参数说明 camera_type 摄像头类型
+// 参数说明 *image_addr 图像首地址
+// 参数说明 boundary_num 图像中包含边界数量
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_data_send (detector_image_type_enum camera_type, void *image_addr, uint8 boundary_num, uint16 width, uint16 height)
+{
+ uint32 image_size = 0;
+
+ detector_camera_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_data.function = DETECTOR_CAMERA_FUNCTION;
+ detector_camera_data.camera_type = (camera_type << 5) | ((image_addr != NULL ? 0 : 1) << 4) | boundary_num;
+ // 写入包长度信息,仅包含协议部分
+ detector_camera_data.length = sizeof(detector_camera_struct);
+ detector_camera_data.image_width = width;
+ detector_camera_data.image_height = height;
+
+ // 首先发送帧头、功能、摄像头类型、以及宽度高度等信息
+ detector_transfer(&detector_camera_data, sizeof(detector_camera_struct));
+
+ // 根据摄像头类型计算图像大小
+ switch(camera_type)
+ {
+ case DETECTOR_OV7725_BIN:
+ {
+ image_size = width * height / 8;
+ }break;
+
+ case DETECTOR_MT9V03X:
+ {
+ image_size = width * height;
+ }break;
+
+ case DETECTOR_SCC8660:
+ {
+ image_size = width * height * 2;
+ }break;
+ }
+
+ // 发送图像数据
+ if(NULL != image_addr)
+ {
+ detector_transfer(image_addr, image_size);
+ }
+
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 图像边线绘制函数
+// 参数说明 boundary_id 边线ID
+// 参数说明 dot_num 点数量
+// 参数说明 *dot_x 横坐标数据首地址
+// 参数说明 *dot_y 纵坐标数据首地址
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_dot_send (detector_camera_buffer_struct *buffer)
+{
+ uint8 i;
+ uint16 dot_bytes = 0; // 点字节数量
+ wifi_spi_send_multi_struct multi_buffer;
+
+ dot_bytes = detector_camera_dot_data.dot_num;
+
+ if(detector_camera_dot_data.dot_type & (1 << 5))
+ {
+ dot_bytes *= 2;
+ }
+
+ // 边线发送时 WIFI SPI采用多源地址发送函数,可以极大提高发送速度
+ if(DETECTOR_WIFI_SPI == detector_transfer_type)
+ {
+ multi_buffer.source[0] = (uint8 *)&detector_camera_dot_data;
+ multi_buffer.length[0] = sizeof(detector_camera_dot_struct);
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ multi_buffer.source[i * 2 + 1] = buffer->boundary_x[i];
+ multi_buffer.source[i * 2 + 2] = buffer->boundary_y[i];
+
+ multi_buffer.length[i * 2 + 1] = dot_bytes;
+ multi_buffer.length[i * 2 + 2] = dot_bytes;
+ }
+
+ wifi_spi_send_buffer_multi(&multi_buffer);
+ }
+ else
+ {
+ // 首先发送帧头、功能、边界编号、坐标长度、点个数
+ detector_transfer(&detector_camera_dot_data, sizeof(detector_camera_dot_struct));
+
+ for(i=0; i < DETECTOR_CAMERA_MAX_BOUNDARY; i++)
+ {
+ // 判断是否发送横坐标数据
+ if(NULL != buffer->boundary_x[i])
+ {
+ detector_transfer(buffer->boundary_x[i], dot_bytes);
+ }
+
+ // 判断是否发送纵坐标数据
+ if(NULL != buffer->boundary_y[i])
+ {
+ // 如果没有纵坐标数据,则表示每一行只有一个边界
+ // 指定了横纵坐标数据,这种方式可以实现同一行多个边界的情况,例如搜线算法能够搜索出回弯。
+ detector_transfer(buffer->boundary_y[i], dot_bytes);
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 虚拟示波器发送函数
+// 参数说明 *detector_oscilloscope 示波器数据结构体
+// 返回参数 void
+// 使用示例 detector_oscilloscope_send(&detector_oscilloscope_data);
+//-------------------------------------------------------------------------------------------------------------------
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope)
+{
+ uint8 packet_size;
+
+ // 将高四位清空
+ detector_oscilloscope->channel_num &= 0x0f;
+
+ zf_assert(DETECTOR_SET_OSCILLOSCOPE_COUNT >= detector_oscilloscope->channel_num);
+
+ // 帧头
+ detector_oscilloscope->head = DETECTOR_SEND_HEAD;
+
+ // 写入包长度信息
+ packet_size = sizeof(detector_oscilloscope_struct) - (DETECTOR_SET_OSCILLOSCOPE_COUNT - detector_oscilloscope->channel_num) * 4;
+ detector_oscilloscope->length = packet_size;
+
+ // 写入功能字与通道数量
+ detector_oscilloscope->channel_num |= DETECTOR_CAMERA_OSCILLOSCOPE;
+
+ // 和校验计算
+ detector_oscilloscope->check_sum = 0;
+ detector_oscilloscope->check_sum = detector_sum((uint8 *)&detector_oscilloscope_data, packet_size);
+
+ // 数据在调用本函数之前,由用户将需要发送的数据写入detector_oscilloscope_data.data[]
+
+ detector_transfer((uint8 *)detector_oscilloscope, packet_size);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像信息配置函数
+// 参数说明 camera_type 图像类型
+// 参数说明 image_addr 图像地址 如果传递NULL参数则表示只发送边线信息到上位机
+// 参数说明 width 图像宽度
+// 参数说明 height 图像高度
+// 返回参数 void
+// 使用示例 detector_camera_information_config(DETECTOR_MT9V03X, mt9v03x_image[0], MT9V03X_W, MT9V03X_H);
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height)
+{
+ detector_camera_dot_data.head = DETECTOR_SEND_HEAD;
+ detector_camera_dot_data.function = DETECTOR_CAMERA_DOT_FUNCTION;
+ // 写入包长度信息
+ detector_camera_dot_data.length = sizeof(detector_camera_dot_struct);
+
+ detector_camera_buffer.camera_type = camera_type;
+ detector_camera_buffer.image_addr = image_addr;
+ detector_camera_buffer.width = width;
+ detector_camera_buffer.height = height;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客图像边线发送配置函数
+// 参数说明 boundary_type 边界类型
+// 参数说明 dot_num 一条边界有多少个点
+// 参数说明 dot_x1 存放边线1横坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_x2 存放边线2横坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_x3 存放边线3横坐标的地址 如果传递NULL参数则表示不发送边线3
+// 参数说明 dot_y1 存放边线1纵坐标的地址 如果传递NULL参数则表示不发送边线1
+// 参数说明 dot_y2 存放边线2纵坐标的地址 如果传递NULL参数则表示不发送边线2
+// 参数说明 dot_y3 存放边线3纵坐标的地址 如果传递NULL参数则表示不发送边线3
+// 返回参数 void
+// 使用示例 detector_camera_config(X_BOUNDARY, MT9V03X_H, x1_boundary, x2_boundary, x3_boundary, NULL, NULL, NULL); // 图像发送时包含三条边线,边线只有横坐标
+// 使用示例 detector_camera_config(Y_BOUNDARY, MT9V03X_W, NULL, NULL, NULL, y1_boundary, y2_boundary, y3_boundary); // 图像发送时包含三条边线,边线只有纵坐标
+// 使用示例 detector_camera_config(XY_BOUNDARY, 160, xy_x1_boundary, xy_x2_boundary, xy_x3_boundary, xy_y1_boundary, xy_y2_boundary, xy_y3_boundary); // 图像发送时包含三条边线,边线包含横纵坐标
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3)
+{
+ uint8 i = 0;
+ uint8 boundary_num = 0;
+ uint8 boundary_data_type = 0;
+
+ // 检查图像发送缓冲区是否准备就绪, 调用此函数之前需要先调用detector_camera_config设置好图像信息
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_dot_data.dot_num = dot_num;
+
+ detector_camera_dot_data.valid_flag = 0;
+ for(i = 0; i < 3; i++)
+ {
+ detector_camera_buffer.boundary_x[i] = NULL;
+ detector_camera_buffer.boundary_y[i] = NULL;
+ }
+
+ switch(boundary_type)
+ {
+ case X_BOUNDARY:
+ {
+ if(NULL != dot_x1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i++] = dot_x1;
+ }
+ if(NULL != dot_x2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i++] = dot_x2;
+ }
+ if(NULL != dot_x3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i++] = dot_x3;
+ }
+
+ if(255 < detector_camera_buffer.height)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case Y_BOUNDARY:
+ {
+ if(NULL != dot_y1)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if(NULL != dot_y2)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if(NULL != dot_y3)
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if(255 < detector_camera_buffer.width)
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case XY_BOUNDARY:
+ {
+ if((NULL != dot_x1) && (NULL != dot_y1))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 0;
+ detector_camera_buffer.boundary_x[i] = dot_x1;
+ detector_camera_buffer.boundary_y[i++] = dot_y1;
+ }
+ if((NULL != dot_x2) && (NULL != dot_y2))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 1;
+ detector_camera_buffer.boundary_x[i] = dot_x2;
+ detector_camera_buffer.boundary_y[i++] = dot_y2;
+ }
+ if((NULL != dot_x3) && (NULL != dot_y3))
+ {
+ boundary_num++;
+ detector_camera_dot_data.valid_flag |= 1 << 2;
+ detector_camera_buffer.boundary_x[i] = dot_x3;
+ detector_camera_buffer.boundary_y[i++] = dot_y3;
+ }
+
+ if((255 < detector_camera_buffer.width) || (255 < detector_camera_buffer.height))
+ {
+ boundary_data_type = 1;
+ }
+ }break;
+
+ case NO_BOUNDARY:break;
+ }
+
+ detector_camera_dot_data.dot_type = (boundary_type << 6) | (boundary_data_type << 5) | boundary_num;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客发送摄像头图像
+// 参数说明 void
+// 返回参数 void
+// 使用示例
+// 备注信息 在调用图像发送函数之前,请务必调用一次detector_camera_config函数,将对应的参数设置好
+//-------------------------------------------------------------------------------------------------------------------
+void detector_camera_send (void)
+{
+ // 检查图像发送缓冲区是否准备就绪
+ zf_assert(0 != detector_camera_buffer.camera_type);
+
+ detector_camera_data_send(detector_camera_buffer.camera_type, detector_camera_buffer.image_addr, detector_camera_dot_data.dot_type & 0x0f, detector_camera_buffer.width, detector_camera_buffer.height);
+
+ if(detector_camera_dot_data.dot_type & 0x0f)
+ {
+ detector_camera_dot_send(&detector_camera_buffer);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客解析接收到的数据
+// 参数说明 void
+// 返回参数 void
+// 使用示例 函数只需要放到周期运行的PIT中断或者主循环即可
+//-------------------------------------------------------------------------------------------------------------------
+void detector_data_analysis (void)
+{
+ uint8 temp_sum;
+ uint32 read_length;
+ detector_parameter_struct *receive_packet;
+
+ // 这里使用uint32进行定义,目的是为了保证数组四字节对齐
+ uint32 temp_buffer[DETECTOR_BUFFER_SIZE / 4];
+
+ // 尝试读取数据, 如果不是自定义的传输方式则从接收回调中读取数据
+ if(DETECTOR_CUSTOM != detector_transfer_type)
+ {
+ read_length = detector_receive_callback((uint8 *)temp_buffer, DETECTOR_BUFFER_SIZE);
+ if(read_length)
+ {
+ // 将读取到的数据写入FIFO
+ fifo_write_buffer(&detector_fifo, (uint8 *)temp_buffer, read_length);
+ }
+ }
+
+ while(sizeof(detector_parameter_struct) <= fifo_used(&detector_fifo))
+ {
+ read_length = sizeof(detector_parameter_struct);
+ fifo_read_buffer(&detector_fifo, (uint8 *)temp_buffer, &read_length, FIFO_READ_ONLY);
+
+ if(DETECTOR_RECEIVE_HEAD != ((uint8 *)temp_buffer)[0])
+ {
+ // 没有帧头则从FIFO中去掉第一个数据
+ read_length = 1;
+ }
+ else
+ {
+ // 找到帧头
+ receive_packet = (detector_parameter_struct *)temp_buffer;
+ temp_sum = receive_packet->check_sum;
+ receive_packet->check_sum = 0;
+ if(temp_sum == detector_sum((uint8 *)temp_buffer, sizeof(detector_parameter_struct)))
+ {
+ // 和校验成功保存数据
+ detector_parameter[receive_packet->channel - 1] = receive_packet->data;
+ }
+ else
+ {
+ read_length = 1;
+ }
+ }
+
+ // 丢弃无需使用的数据
+ fifo_read_buffer(&detector_fifo, NULL, &read_length, FIFO_READ_AND_CLEAN);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 滴答客 初始化
+// 参数说明 transfer_type 选择使用哪种方式传输数据
+// 返回参数 void
+// 使用示例
+//-------------------------------------------------------------------------------------------------------------------
+void detector_init (detector_transfer_type_enum transfer_type)
+{
+ detector_transfer_type = transfer_type;
+
+ fifo_init(&detector_fifo, FIFO_DATA_8BIT, detector_buffer, DETECTOR_BUFFER_SIZE);
+
+ switch(detector_transfer_type)
+ {
+ case DETECTOR_DEBUG_UART:
+ {
+ detector_transfer_callback = debug_send_buffer;
+ detector_receive_callback = debug_read_ring_buffer;
+ }break;
+
+ case DETECTOR_WIRELESS_UART:
+ {
+ detector_transfer_callback = wireless_uart_send_buffer;
+ detector_receive_callback = wireless_uart_read_buffer;
+ }break;
+
+ case DETECTOR_CH9141:
+ {
+ detector_transfer_callback = bluetooth_ch9141_send_buffer;
+ detector_receive_callback = bluetooth_ch9141_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_UART:
+ {
+ detector_transfer_callback = wifi_uart_send_buffer;
+ detector_receive_callback = wifi_uart_read_buffer;
+ }break;
+
+ case DETECTOR_WIFI_SPI:
+ {
+ detector_transfer_callback = wifi_spi_send_buffer;
+ detector_receive_callback = wifi_spi_read_buffer;
+ }break;
+
+ case DETECTOR_CUSTOM:
+ {
+ // 根据自己的需求 自行实现detector_custom_write_byte函数,完成数据的传输
+ detector_transfer_callback = detector_custom_transfer;
+
+ // 无需设置接收回调
+
+ // 在合适的位置调用detector_custom_receive 或者 detector_custom_receive_byte函数即可实现数据接收
+ // detector_custom_receive 或者 detector_custom_receive_byte函数 只需调用一个函数即可,根据自己的需求是按字节接收数据还是按照数据接收数据
+ // 接收到的数据会被写入detector_fifo中, 以备解析函数使用
+ //detector_receive_callback = detector_custom_receive;
+
+ }break;
+ }
+}
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_detector.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_detector.h
new file mode 100644
index 0000000..ee2ea7e
--- /dev/null
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_detector.h
@@ -0,0 +1,173 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_detector
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+
+#ifndef _zf_device_detector_h_
+#define _zf_device_detector_h_
+
+#include "zf_common_typedef.h"
+#include "zf_common_debug.h"
+
+// 定义接收FIFO大小
+#define DETECTOR_BUFFER_SIZE ( 0x40 )
+
+// 定义示波器的最大通道数量
+#define DETECTOR_SET_OSCILLOSCOPE_COUNT ( 0x08 )
+
+// 定义参数调试的最大通道数量
+#define DETECTOR_SET_PARAMETR_COUNT ( 0x08 )
+
+// 定义图像边线最大数量
+#define DETECTOR_CAMERA_MAX_BOUNDARY ( 0x08 )
+
+// 单片机往上位机发送的帧头
+#define DETECTOR_SEND_HEAD ( 0xAA )
+
+// 摄像头类
+#define DETECTOR_CAMERA_FUNCTION ( 0x02 )
+#define DETECTOR_CAMERA_DOT_FUNCTION ( 0x03 )
+#define DETECTOR_CAMERA_OSCILLOSCOPE ( 0x10 )
+
+// 上位机往单片机发送的帧头
+#define DETECTOR_RECEIVE_HEAD ( 0x55 )
+
+// 参数设置类
+#define DETECTOR_RECEIVE_SET_PARAMETER ( 0x20 )
+
+
+// 数据发送设备枚举
+typedef enum
+{
+ DETECTOR_DEBUG_UART, // 调试串口 使用的串口由DEBUG_UART_INDEX宏定义指定
+ DETECTOR_WIRELESS_UART, // 无线转串口
+ DETECTOR_CH9141, // 9141蓝牙
+ DETECTOR_WIFI_UART, // WIFI转串口
+ DETECTOR_WIFI_SPI, // 高速WIFI SPI
+ DETECTOR_CUSTOM, // 自定义通讯方式 需要自行detector_custom_write_byte函数中实现数据发送
+}detector_transfer_type_enum;
+
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ DETECTOR_OV7725_BIN = 1,
+ DETECTOR_MT9V03X,
+ DETECTOR_SCC8660,
+
+ // 按照图像类型定义
+ DETECTOR_BINARY = 1,
+ DETECTOR_GRAY,
+ DETECTOR_RGB565,
+}detector_image_type_enum;
+
+// 摄像头类型枚举
+typedef enum
+{
+ // 按照摄像头型号定义
+ X_BOUNDARY, // 发送的图像中边界信息只包含X,也就是只有横坐标信息,纵坐标根据图像高度得到
+ Y_BOUNDARY, // 发送的图像中边界信息只包含Y,也就是只有纵坐标信息,横坐标根据图像宽度得到,通常很少有这样的需求
+ XY_BOUNDARY, // 发送的图像中边界信息包含X与Y,这样可以指定点在任意位置,就可以方便显示出回弯的效果
+ NO_BOUNDARY, // 发送的图像中没有边线信息
+}detector_boundary_type_enum;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 channel_num; // 高四位为功能字 低四位为通道数量
+ uint8 check_sum; // 和校验
+ uint8 length; // 包长度
+ float data[DETECTOR_SET_OSCILLOSCOPE_COUNT]; // 通道数据
+}detector_oscilloscope_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 camera_type; // 低四位表示边界数量 第四位表示是否有图像数据 例如0x13:其中3表示一副图像有三条边界(通常是左边界、中线、右边界)、1表示没有图像数据
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 image_width; // 图像宽度
+ uint16 image_height; // 图像高度
+}detector_camera_struct;
+
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 dot_type; // 点类型 BIT5:1:坐标是16位的 0:坐标是8位的 BIT7-BIT6:0:只有X坐标 1:只有Y坐标 2:X和Y坐标都有 BIT3-BIT0:边界数量
+ uint8 length; // 包长度(仅包含协议部分)
+ uint16 dot_num; // 画点数量
+ uint8 valid_flag; // 通道标识
+ uint8 reserve; // 保留
+}detector_camera_dot_struct;
+
+typedef struct
+{
+ void *image_addr; // 摄像头地址
+ uint16 width; // 图像宽度
+ uint16 height; // 图像高度
+ detector_image_type_enum camera_type; // 摄像头类型
+ void *boundary_x[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界横坐标数组地址
+ void *boundary_y[DETECTOR_CAMERA_MAX_BOUNDARY]; // 边界纵坐标数组地址
+}detector_camera_buffer_struct;
+
+typedef struct
+{
+ uint8 head; // 帧头
+ uint8 function; // 功能字
+ uint8 channel; // 通道
+ uint8 check_sum; // 和校验
+ float data; // 数据
+}detector_parameter_struct;
+
+
+extern detector_oscilloscope_struct detector_oscilloscope_data; // 虚拟示波器数据
+extern float detector_parameter[DETECTOR_SET_PARAMETR_COUNT]; // 保存接收到的参数
+
+
+void detector_oscilloscope_send (detector_oscilloscope_struct *detector_oscilloscope);
+
+void detector_camera_information_config (detector_image_type_enum camera_type, void *image_addr, uint16 width, uint16 height);
+void detector_camera_boundary_config (detector_boundary_type_enum boundary_type, uint16 dot_num, void *dot_x1, void *dot_x2, void *dot_x3, void *dot_y1, void *dot_y2, void *dot_y3);
+void detector_camera_send (void);
+
+void detector_data_analysis (void);
+void detector_init (detector_transfer_type_enum transfer_type);
+
+
+
+#endif
+
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1a.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1a.c
index 9c00e9a..3e7410c 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1a.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1a.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1a.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1a.h
index 5d9ea10..89145d3 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1a.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1a.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_dl1a
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1b.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1b.c
new file mode 100644
index 0000000..90e64b3
--- /dev/null
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1b.c
@@ -0,0 +1,217 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+********************************************************************************************************************/
+
+#include "zf_common_debug.h"
+
+#include "zf_driver_delay.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_soft_iic.h"
+
+#include "zf_device_dl1b.h"
+#include "zf_device_config.h"
+#include "zf_device_type.h"
+
+uint8 dl1b_init_flag = 0;
+uint8 dl1b_finsh_flag = 0;
+uint16 dl1b_distance_mm = 8192;
+
+#if DL1B_USE_SOFT_IIC
+static soft_iic_info_struct dl1b_iic_struct;
+
+#define dl1b_transfer_8bit_array(tdata, tlen, rdata, rlen) (soft_iic_transfer_8bit_array(&dl1b_iic_struct, (tdata), (tlen), (rdata), (rlen)))
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 返回以毫米为单位的范围读数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_get_distance();
+// 备注信息 在开始单次射程测量后也调用此函数
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_get_distance (void)
+{
+ if(dl1b_init_flag)
+ {
+ uint8 data_buffer[3] = {0};
+ int16 dl1b_distance_temp = 0;
+
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(data_buffer[2])
+ {
+
+ data_buffer[0] = DL1B_SYSTEM__INTERRUPT_CLEAR >> 8;
+ data_buffer[1] = DL1B_SYSTEM__INTERRUPT_CLEAR & 0xFF;
+ data_buffer[2] = 0x01;
+ dl1b_transfer_8bit_array(data_buffer, 3, data_buffer, 0);// clear Interrupt
+
+ data_buffer[0] = DL1B_RESULT__RANGE_STATUS >> 8;
+ data_buffer[1] = DL1B_RESULT__RANGE_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+
+ if(0x89 == data_buffer[2])
+ {
+ data_buffer[0] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 >> 8;
+ data_buffer[1] = DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, data_buffer, 2);
+ dl1b_distance_temp = data_buffer[0];
+ dl1b_distance_temp = (dl1b_distance_temp << 8) | data_buffer[1];
+
+ if(dl1b_distance_temp > 4000 || dl1b_distance_temp < 0)
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ else
+ {
+ dl1b_distance_mm = dl1b_distance_temp;
+ dl1b_finsh_flag = 1;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+ else
+ {
+ dl1b_distance_mm = 8192;
+ dl1b_finsh_flag = 0;
+ }
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 DL1B INT 中断响应处理函数
+// 参数说明 void
+// 返回参数 void
+// 使用示例 dl1b_int_handler();
+// 备注信息 本函数需要在 DL1B_INT_PIN 对应的外部中断处理函数中调用
+//-------------------------------------------------------------------------------------------------------------------
+void dl1b_int_handler (void)
+{
+#if DL1B_INT_ENABLE
+ dl1b_get_distance();
+#endif
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 初始化 DL1B
+// 参数说明 void
+// 返回参数 uint8 1-初始化失败 0-初始化成功
+// 使用示例 dl1b_init();
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint8 dl1b_init (void)
+{
+ uint8 return_state = 0;
+ uint8 data_buffer[2 + sizeof(dl1b_config_file)];
+ uint16 time_out_count = 0;
+
+#if DL1B_USE_SOFT_IIC
+ soft_iic_init(&dl1b_iic_struct, DL1B_DEV_ADDR, DL1B_SOFT_IIC_DELAY, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#else
+ iic_init(DL1B_IIC, DL1B_DEV_ADDR, DL1B_IIC_SPEED, DL1B_SCL_PIN, DL1B_SDA_PIN);
+#endif
+ gpio_init(DL1B_XS_PIN, GPO, GPIO_HIGH, GPO_PUSH_PULL);
+
+ do
+ {
+ system_delay_ms(50);
+ gpio_low(DL1B_XS_PIN);
+ system_delay_ms(10);
+ gpio_high(DL1B_XS_PIN);
+ system_delay_ms(50);
+
+ data_buffer[0] = DL1B_FIRMWARE__SYSTEM_STATUS >> 8;
+ data_buffer[1] = DL1B_FIRMWARE__SYSTEM_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ return_state = (0x01 == (data_buffer[2] & 0x01)) ? (0) : (1);
+ if(1 == return_state)
+ {
+ break;
+ }
+
+ data_buffer[0] = DL1B_I2C_SLAVE__DEVICE_ADDRESS >> 8;
+ data_buffer[1] = DL1B_I2C_SLAVE__DEVICE_ADDRESS & 0xFF;
+ memcpy(&data_buffer[2], (uint8 *)dl1b_config_file, sizeof(dl1b_config_file));
+ dl1b_transfer_8bit_array(data_buffer, 2 + sizeof(dl1b_config_file), data_buffer, 0);
+
+ while(1)
+ {
+ data_buffer[0] = DL1B_GPIO__TIO_HV_STATUS >> 8;
+ data_buffer[1] = DL1B_GPIO__TIO_HV_STATUS & 0xFF;
+ dl1b_transfer_8bit_array(data_buffer, 2, &data_buffer[2], 1);
+ if(0x00 == (data_buffer[2] & 0x01))
+ {
+ time_out_count = 0;
+ break;
+ }
+ if(DL1B_TIMEOUT_COUNT < time_out_count ++)
+ {
+ return_state = 1;
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ dl1b_init_flag = 1;
+ }while(0);
+
+#if DL1B_INT_ENABLE
+ exti_init(DL1B_INT_PIN, EXTI_TRIGGER_FALLING);
+ dl1b_int_handler();
+ dl1b_finsh_flag = 0;
+#endif
+ set_tof_type(TOF_DL1B, dl1b_int_handler);
+
+ return return_state;
+}
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1b.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1b.h
new file mode 100644
index 0000000..b144739
--- /dev/null
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_dl1b.h
@@ -0,0 +1,99 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_dl1b
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2022-09-15 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* SCL 查看 zf_device_dl1b.h 中 DL1B_SCL_PIN 宏定义
+* SDA 查看 zf_device_dl1b.h 中 DL1B_SDA_PIN 宏定义
+* XS 查看 zf_device_dl1b.h 中 DL1B_XS_PIN 宏定义
+* VCC 5V 电源
+* GND 电源地
+* ------------------------------------
+* ------------------------------------
+********************************************************************************************************************/
+
+#ifndef _ZF_DEVICE_DL1B_H_
+#define _ZF_DEVICE_DL1B_H_
+
+#include "zf_common_typedef.h"
+
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+// 需要注意的是 DL1B 最高支持 400KHz 的 IIC 通信速率
+
+#define DL1B_USE_SOFT_IIC ( 1 ) // 默认使用软件 IIC 方式驱动 建议使用软件 IIC 方式
+#if DL1B_USE_SOFT_IIC // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
+//====================================================软件 IIC 驱动====================================================
+#define DL1B_SOFT_IIC_DELAY ( 10 ) // 软件 IIC 的时钟延时周期 数值越小 IIC 通信速率越快
+#define DL1B_SCL_PIN ( P33_4 ) // 软件 IIC SCL 引脚 连接 DL1B 的 SCL 引脚
+#define DL1B_SDA_PIN ( P33_5 ) // 软件 IIC SDA 引脚 连接 DL1B 的 SDA 引脚
+//====================================================软件 IIC 驱动====================================================
+#else
+#error "暂不支持硬件IIC通讯"
+#endif
+
+#define DL1B_XS_PIN ( P20_10 )
+
+#define DL1B_INT_ENABLE ( 0 ) // 是否启用 INT 引脚 启用则会自动更新数据
+#if DL1B_INT_ENABLE
+#define DL1B_INT_PIN ( ERU_CH1_REQ10_P14_3 )
+#endif
+
+#define DL1B_TIMEOUT_COUNT ( 1000 ) // DL1B 超时计数
+
+//================================================定义 DL1B 内部地址================================================
+
+#define DL1B_DEV_ADDR ( 0x52 >> 1 ) // 0b0101001
+
+#define DL1B_I2C_SLAVE__DEVICE_ADDRESS ( 0x0001 )
+#define DL1B_GPIO__TIO_HV_STATUS ( 0x0031 )
+#define DL1B_SYSTEM__INTERRUPT_CLEAR ( 0x0086 )
+#define DL1B_RESULT__RANGE_STATUS ( 0x0089 )
+#define DL1B_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 ( 0x0096 )
+#define DL1B_FIRMWARE__SYSTEM_STATUS ( 0x00E5 )
+
+//================================================定义 DL1B 内部地址================================================
+
+extern uint8 dl1b_finsh_flag;
+extern uint16 dl1b_distance_mm;
+
+void dl1b_get_distance (void);
+
+void dl1b_int_handler (void);
+uint8 dl1b_init (void);
+
+#endif
+
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_gps_tau1201.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_gps_tau1201.c
index d1517d7..6ab1ea7 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_gps_tau1201.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_gps_tau1201.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_gps_tau1201.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_gps_tau1201.h
index 413700f..c167bae 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_gps_tau1201.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_gps_tau1201.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_gps_tau1201
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_icm20602.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_icm20602.c
index b13125b..f4ae830 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_icm20602.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_icm20602.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_icm20602.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_icm20602.h
index 261a244..67724ad 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_icm20602.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_icm20602.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_icm20602
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu660ra.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu660ra.c
index 4661c0a..fd884cb 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu660ra.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu660ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -231,11 +231,11 @@ uint8 imu660ra_init (void)
return_state = 1;
break;
}
- imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
+ imu660ra_write_register(IMU660RA_PWR_CONF, 0x00); // 关闭高级省电模式
system_delay_ms(1);
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x00); // 开始对模块进行初始化配置
imu660ra_write_registers(IMU660RA_INIT_DATA, imu660ra_config_file, sizeof(imu660ra_config_file)); // 输出配置文件
- imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
+ imu660ra_write_register(IMU660RA_INIT_CTRL, 0x01); // 初始化配置结束
system_delay_ms(20);
if(1 != imu660ra_read_register(IMU660RA_INT_STA)) // 检查是否配置完成
{
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu660ra.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu660ra.h
index 4583819..203292a 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu660ra.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu660ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu660ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu963ra.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu963ra.c
index d8b9c4b..92ec0f6 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu963ra.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu963ra.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu963ra.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu963ra.h
index 2ed160a..4d0d9f9 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu963ra.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_imu963ra.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_imu963ra
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips114.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips114.c
index b3851cd..2182882 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips114.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips114.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips114.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips114.h
index 2f3c8ab..178dbc3 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips114.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips114.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips114
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips200.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips200.c
index b79fabf..722d665 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips200.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips200.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -125,8 +125,8 @@ static soft_spi_info_struct ips200_spi;
#endif
//-------------------------------------------------------------------------------------------------------------------
-// @brief 内部调用,用户无需关心
-// @param dat 数据
+// 函数简介 内部调用,用户无需关心
+// 参数说明 dat 数据
// @return
// @since v1.0
// Sample usage:
@@ -139,10 +139,10 @@ static void ips200_write_data(uint8 dat)
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 写命令 内部调用
-// @param command 命令
+// 函数简介 IPS200 写命令 内部调用
+// 参数说明 command 命令
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_command (const uint8 command)
{
@@ -165,10 +165,10 @@ static void ips200_write_command (const uint8 command)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 8bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 8bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
static void ips200_write_8bit_data (const uint8 dat)
{
@@ -189,10 +189,10 @@ static void ips200_write_8bit_data (const uint8 dat)
}
//-------------------------------------------------------------------------------------------------------------------
-// @brief IPS200 向液晶屏写 16bit 数据 内部调用
-// @param dat 数据
+// 函数简介 IPS200 向液晶屏写 16bit 数据 内部调用
+// 参数说明 dat 数据
// @return void
-// @note 内部调用 用户无需关心
+// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
void ips200_write_16bit_data (const uint16 dat)
{
@@ -1068,7 +1068,6 @@ void ips200_init (ips200_type_enum type_select)
system_delay_ms(5);
IPS200_RST(1);
system_delay_ms(120);
-
if(IPS200_TYPE_SPI == ips200_display_type)
{
IPS200_CS(0);
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips200.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips200.h
index c27b776..cc4cdf8 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips200.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ips200.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ips200
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_key.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_key.c
index 0495d3f..9e42c8a 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_key.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_key.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_key.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_key.h
index bad1fa7..bcab8aa 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_key.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_key.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_key
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mpu6050.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mpu6050.c
index 6dd3554..dc3c5b2 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mpu6050.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mpu6050.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mpu6050.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mpu6050.h
index 32da0fe..3510e06 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mpu6050.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mpu6050.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mpu6050
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mt9v03x.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mt9v03x.c
index 8544616..231cfec 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mt9v03x.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mt9v03x.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mt9v03x.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mt9v03x.h
index 64c4d69..7786bc5 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mt9v03x.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_mt9v03x.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_mt9v03x
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_oled.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_oled.c
index 1e15fe7..d4a9e35 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_oled.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_oled.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_oled.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_oled.h
index ac85c43..e641410 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_oled.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_oled.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_oled
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ov7725.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ov7725.c
index cfac954..28f8a7d 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ov7725.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ov7725.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ov7725.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ov7725.h
index ed46ae5..f45a4e8 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ov7725.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_ov7725.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_ov7725
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_scc8660.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_scc8660.c
index 2536b2d..3483c93 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_scc8660.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_scc8660.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_scc8660.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_scc8660.h
index 9ef3219..815d272 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_scc8660.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_scc8660.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_scc8660
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -76,17 +76,17 @@
#define SCC8660_H (120) // 实际图像分辨率高度 可选参数为:120 160
#define SCC8660_IMAGE_SIZE (SCC8660_W * 2 * SCC8660_H) // 整体图像大小 SCC8660_W*2*SCC8660_H 不能超过 65535
-#define SCC8660_AUTO_EXP_DEF (1 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
-#define SCC8660_BRIGHT_DEF (100) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
+#define SCC8660_AUTO_EXP_DEF (0 ) // 自动曝光 默认不开启自动曝光设置 范围 [0-1] 0为关闭
+#define SCC8660_BRIGHT_DEF (300) // 亮度设置 手动曝光默认:300 手动曝光时:参数范围0-65535 自动曝光推荐值:100 自动曝光时参数设置范围0-255
#define SCC8660_FPS_DEF (50 ) // 图像帧率 默认:50 可选参数为:60 50 30 25。 实际帧率还需要看SCC8660_PCLK_DIV参数的设置
#define SCC8660_PCLK_DIV_DEF (5 ) // PCLK分频系数 默认:5 可选参数为:<0:1/1> <1:2/3> <2:1/2> <3:1/3> <4:1/4> <5:1/8>
// 分频系数越大,PCLK频率越低,降低PCLK可以减轻DVP接口的干扰,但降低PCLK频率则会影响帧率。若无特殊需求请保持默认。
// 例如设置FPS为50帧,但是pclk分频系数选择的为5,则摄像头输出的帧率为50*(1/8)=6.25帧
// 其他参数不变的情况下,SCC8660_PCLK_DIV参数越大图像会越亮
-#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
-#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
-#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
-#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
+#define SCC8660_PCLK_MODE_DEF (0 ) // PCLK模式 默认:0 可选参数为:[0,1] 0:不输出消隐信号 1:输出消隐信号 <通常都设置为0,如果使用STM32的DCMI接口采集需要设置为1>
+#define SCC8660_COLOR_MODE_DEF (1 ) // 图像色彩模式 默认:0 可选参数为:[0,1] 0:正常彩色模式 1:鲜艳模式(色彩饱和度提高)
+#define SCC8660_DATA_FORMAT_DEF (1 ) // 输出数据格式 默认:0 可选参数为:[0-3] 0:RGB565 1:RGB565(字节交换) 2:YUV422(YUYV) 3:YUV422(UYVY)
+#define SCC8660_MANUAL_WB_DEF (0 ) // 手动白平衡 默认:0 可选参数为:[0,0x65-0xa0] 0:关闭手动白平衡,启用自动白平衡 其他:手动白平衡 手动白平衡时 参数范围0x65-0xa0
//================================================定义 SCC8660 参数配置================================================
//===============================================定义 SCC8660 参数结构体================================================
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tft180.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tft180.c
index a044475..a0d7378 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tft180.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tft180.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tft180.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tft180.h
index 5b3fd52..927ccac 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tft180.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tft180.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tft180
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tsl1401.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tsl1401.c
index 959fe8a..3f9db7f 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tsl1401.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tsl1401.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tsl1401.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tsl1401.h
index dbe752e..1fab12e 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tsl1401.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_tsl1401.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_tsl1401
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_type.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_type.c
index 8c086cf..497ba55 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_type.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_type.c
@@ -24,26 +24,31 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#include "zf_device_type.h"
static void type_default_callback(void);
-camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
-callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
-callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
+camera_type_enum camera_type = NO_CAMERE; // 摄像头类型变量
+callback_function camera_uart_handler = type_default_callback; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_vsync_handler = type_default_callback; // 场中断函数指针,根据初始化时设置的函数进行跳转
+callback_function camera_dma_handler = type_default_callback; // DMA完成中断函数指针,根据初始化时设置的函数进行跳转
wireless_type_enum wireless_type = NO_WIRELESS;
-callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_uart_handler = type_default_callback; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
+callback_function wireless_module_spi_handler = type_default_callback; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+tof_type_enum tof_type = NO_TOF;
+callback_function tof_module_exti_handler = type_default_callback; // ToF 模块 INT 更新中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 默认回调函数
@@ -82,9 +87,30 @@ void set_camera_type (camera_type_enum type_set, callback_function vsync_callba
// 使用示例 set_wireless_type(WIRELESS_UART, uart_callback);
// 备注信息 一般由各摄像头初始化内部调用
//-------------------------------------------------------------------------------------------------------------------
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback)
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback)
{
wireless_type = type_set;
- wireless_module_uart_handler = ((uart_callback == NULL) ? (type_default_callback) : (uart_callback));
+ if(WIFI_SPI == wireless_type)
+ {
+ wireless_module_spi_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+ else
+ {
+ wireless_module_uart_handler = ((wireless_callback == NULL) ? (type_default_callback) : (wireless_callback));
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 设置 ToF 模块类型
+// 参数说明 type_set 选定的 ToF 模块类型
+// 参数说明 exti_callback 设备的外部中断回调函数
+// 返回参数 void
+// 使用示例 set_tof_type(TOF_DL1A, dl1a_int_handler);
+// 备注信息 一般由各摄像头初始化内部调用
+//-------------------------------------------------------------------------------------------------------------------
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback)
+{
+ tof_type = type_set;
+ tof_module_exti_handler = ((exti_callback == NULL) ? (type_default_callback) : (exti_callback));
}
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_type.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_type.h
index 2c0a28f..19c36ca 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_type.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_type.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_type
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -32,6 +32,7 @@
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-28 pudding 增加中文注释说明
+* 2023-05-26 pudding 新增SPI WIFI 中断回调指针
********************************************************************************************************************/
#ifndef _zf_device_type_h_
@@ -55,12 +56,21 @@ typedef enum
WIRELESS_UART, // 无线串口
BLUETOOTH_CH9141, // 蓝牙 CH9141
WIFI_UART, // 串口 WiFi
+ WIFI_SPI // SPI WiFi
}wireless_type_enum;
+
+typedef enum
+{
+ NO_TOF = 0, // 无设备
+ TOF_DL1A, // DL1A
+ TOF_DL1B, // DL1B
+}tof_type_enum;
//==============================================定义 外设 参数结构体==================================================
//===========================================声明 回调函数指针及外设 类型==============================================
typedef void (*callback_function)(void);
+
extern wireless_type_enum wireless_type;
extern callback_function wireless_module_uart_handler; // 无线串口接收中断函数指针,根据初始化时设置的函数进行跳转
@@ -68,12 +78,17 @@ extern camera_type_enum camera_type;
extern callback_function camera_dma_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_vsync_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
extern callback_function camera_uart_handler; // 串口通讯中断函数指针,根据初始化时设置的函数进行跳转
+extern callback_function wireless_module_spi_handler; // WIFI SPI GPIO中断函数指针,根据初始化时设置的函数进行跳转
+
+extern tof_type_enum tof_type; // ToF 模块 类型
+extern callback_function tof_module_exti_handler; // ToF 模块 INT 更新中断
//===========================================声明 回调函数指针及外设 类型==============================================
//=============================================声明 中断回调 基础函数================================================
void set_camera_type (camera_type_enum type_set, callback_function vsync_callback, callback_function dma_callback, callback_function uart_callback);
-void set_wireless_type (wireless_type_enum type_set, callback_function uart_callback);
+void set_wireless_type (wireless_type_enum type_set, callback_function wireless_callback);
+void set_tof_type (tof_type_enum type_set, callback_function exti_callback);
//=============================================声明 中断回调 基础函数================================================
#endif
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_virtual_oscilloscope.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_virtual_oscilloscope.c
index 6e44302..2bdb164 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_virtual_oscilloscope.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_virtual_oscilloscope.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_virtual_oscilloscope.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_virtual_oscilloscope.h
index 2c954e1..f518026 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_virtual_oscilloscope.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_virtual_oscilloscope.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_virtual_oscilloscope
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_spi.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_spi.c
new file mode 100644
index 0000000..d04df4f
--- /dev/null
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_spi.c
@@ -0,0 +1,1400 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+* 2023-05-29 pudding 新增关闭休眠指令,提升通讯效率
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#include "stdio.h"
+#include "zf_common_clock.h"
+#include "zf_common_debug.h"
+#include "zf_common_fifo.h"
+#include "zf_common_function.h"
+#include "zf_driver_delay.h"
+#include "zf_driver_gpio.h"
+#include "zf_common_interrupt.h"
+#include "zf_driver_exti.h"
+#include "zf_driver_spi.h"
+#include "zf_device_type.h"
+
+#include "zf_device_wifi_spi.h"
+
+#define WAIT_TIME_OUT (10000) // 单指令等待时间 单位:ms
+
+#define WIFI_SPI_WRITE_MAX 4092 // 定义一次SPI通讯最大发送的数据长度
+
+#define WIFI_SPI_WRITE_REQUEST 0x01
+#define WIFI_SPI_CHECK_STATE 0x02
+#define WIFI_SPI_WRITE_DATA 0x03
+#define WIFI_SPI_READ_DATA 0x04
+#define WIFI_SPI_WRITE_END 0x07
+#define WIFI_SPI_READ_END 0x08
+
+#define WIFI_SPI_WRITE_ADDR 0x00
+#define WIFI_SPI_STATE_ADDR 0x04
+
+volatile wifi_spi_buffer_state_enum wifi_buffer_state;
+volatile wifi_spi_transmit_state_enum wifi_transmit_state;
+
+static fifo_struct wifi_spi_fifo;
+static uint8 wifi_spi_buffer[WIFI_SPI_BUFFER_SIZE]; // 数据存放数组
+
+vuint8 wifi_spi_ack_flag = 0; // 0:模块未应答 1:模块已应答
+uint8 wifi_spi_init_flag; // 0:模块未初始化成功或者未连接 1:模块已连接并成功初始化
+vuint8 wifi_spi_packet_num; // 发送的数据包ID
+vuint32 wifi_spi_send_remain_length; // 剩余的发送长度
+
+uint8 wifi_spi_receive_buffer[WIFI_SPI_WRITE_MAX];
+
+wifi_spi_information_struct wifi_spi_information;
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 请求写入数据到模块
+// 参数说明 length 需要写入的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_write_request(uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_REQUEST;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+ head.magic = 0xFE;
+ head.sequence = wifi_spi_packet_num++;
+ head.length = length;
+
+ wifi_transmit_state = TRANSMIT_WRITE_REQUEST;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 读取模块状态
+// 参数说明 *length 需要读取或者写入的长度
+// @return WIFI_SPI_BUFFER_STATE_enum 模块状态
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static wifi_spi_buffer_state_enum wifi_spi_read_state(uint16 *length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_CHECK_STATE;
+ head.addr = WIFI_SPI_STATE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_spi_ack_flag = 0;
+ wifi_transmit_state = TRANSMIT_READ_STATE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 7);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+
+ if(BUFFER_WRITE == head.magic)
+ {
+ wifi_spi_packet_num = head.sequence;
+ }
+ *length = head.length;
+
+ return (wifi_spi_buffer_state_enum)head.magic;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据发送完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 数据接收完成
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_done(void)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_END;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_transmit_state = TRANSMIT_IDLE;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要写入数据的首地址
+// 参数说明 length 需要写入数据的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data(const uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+ spi_write_8bit_array(WIFI_SPI_INDEX, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_WRITE_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_WRITE;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_write_8bit_array(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, 3);
+
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(NULL != multi_buffer->source[i]) spi_write_8bit_array(WIFI_SPI_INDEX, multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_send_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 接收模块发送的数据
+// 参数说明 *buff 接收数组的缓冲区首地址
+// 参数说明 length 需要接收的长度
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_receive_data(uint8 *buff, uint16 length)
+{
+ wifi_spi_buffer_struct head;
+
+ head.cmd = WIFI_SPI_READ_DATA;
+ head.addr = WIFI_SPI_WRITE_ADDR;
+ head.dummy = 0x00;
+
+ wifi_transmit_state = TRANSMIT_READ;
+ gpio_set_level(WIFI_SPI_CS_PIN, 0);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)&head.cmd, &head.cmd, 3);
+ spi_transfer_8bit(WIFI_SPI_INDEX, (const uint8 *)buff, buff, length);
+ gpio_set_level(WIFI_SPI_CS_PIN, 1);
+ wifi_spi_receive_done();
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送命令到模块
+// 参数说明 *str 命令字符串首地址
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+static void wifi_spi_send_command(const char *str)
+{
+ uint8 state = 0;
+ uint16 send_length;
+ uint16 wait_time = 0;
+
+ // 请求发送数据
+ send_length = (uint16)strlen(str);
+
+ // 等待传输进入空闲
+ while(TRANSMIT_IDLE != wifi_transmit_state);
+
+ // 如果没有进入发送状态则重新请求发送数据
+ while(BUFFER_WRITE != wifi_buffer_state)
+ {
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time++;
+ if((WAIT_TIME_OUT / 4) <= wait_time)
+ {
+ state = 1;
+ wifi_spi_init_flag = 0; // 模块已断开
+ break;
+ }
+ system_delay_ms(1);
+ }
+
+ if(1 == state)
+ {
+ break;
+ }
+ }
+
+ wifi_buffer_state = BUFFER_IDLE;
+
+ if(0 == state) // 通讯未超时
+ {
+ wifi_spi_send_remain_length = send_length;
+ // 发送消息
+ wifi_spi_send_data((const uint8 *)str, send_length);
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 检查模块状态并读取模块发送的数据
+// 参数说明 void
+// @return void
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+void wifi_spi_check_state_read_buffer(void)
+{
+ uint16 wifi_spi_receive_length; // 本次接收到的数据数量
+
+ // 查询WIFI模块的状态
+ wifi_buffer_state = wifi_spi_read_state(&wifi_spi_receive_length);
+
+ // 如果需要读取WIFI模块数据,则保存需要读取的长度
+ if(BUFFER_READ == wifi_buffer_state)
+ {
+ wifi_spi_receive_data((uint8 *)wifi_spi_receive_buffer, wifi_spi_receive_length);
+ fifo_write_buffer(&wifi_spi_fifo, wifi_spi_receive_buffer, wifi_spi_receive_length); // 存入 FIFO
+ }
+ else if(BUFFER_IDLE == wifi_buffer_state)
+ {
+ // 如果模块内部缓冲区状态为空闲,则传输状态也设置为空闲
+ wifi_transmit_state = TRANSMIT_IDLE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块
+// 参数说明 *buff 需要发送的数据首地址
+// 参数说明 length 需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage:
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data(const uint8 *buff, uint32 length)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ wifi_spi_send_remain_length = length;
+
+ while(wifi_spi_send_remain_length)
+ {
+ send_length = (uint16)func_limit_ab(wifi_spi_send_remain_length, 1, WIFI_SPI_WRITE_MAX);
+
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data(buff, send_length);
+ buff += send_length;
+ wifi_spi_send_remain_length -= send_length;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return wifi_spi_send_remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 发送数据到模块(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// @return uint32 剩余未发送长度
+// Sample usage: 发送数据总长度不能超过4092个
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_write_data_multi(wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint16 send_length;
+ uint32 wait_time;
+
+ // 记录需要发送的长度
+ send_length = multi_buffer->length[0] + multi_buffer->length[1] + multi_buffer->length[2] + multi_buffer->length[3] + multi_buffer->length[4] + multi_buffer->length[5] + multi_buffer->length[6] + multi_buffer->length[7];
+
+ if(WIFI_SPI_WRITE_MAX >= send_length)
+ {
+ // 请求发送数据
+ wifi_spi_ack_flag = 0;
+ wifi_spi_write_request(send_length);
+
+ // 最长等待5秒
+ wait_time = 5000;
+ while(!wifi_spi_ack_flag)
+ {
+ wait_time--;
+ if(0 == wait_time) break;
+ system_delay_ms(1);
+ }
+
+ if(BUFFER_WRITE == wifi_buffer_state)
+ {
+ // 发送消息
+ wifi_spi_send_data_multi(multi_buffer);
+ send_length = 0;
+ wifi_buffer_state = BUFFER_IDLE;
+ }
+ }
+
+ return send_length;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 等待模块响应
+// 参数说明 *wait_buffer 等待的响应的字符串
+// 参数说明 timeout 超时时间
+// 返回参数 uint8 0:模块响应指定数据 1:模块未响应指定数据或超时
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_wait_ack (char *wait_buffer, uint32 timeout)
+{
+ uint8 return_state = 1;
+ char receiver_buffer[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ uint32 receiver_len = 8;
+
+ do
+ {
+ system_delay_ms(1);
+ // 判断接收缓冲区内是否有需要响应的指定数据 如果有 则跳出循环并且返回0
+ receiver_len = 8;
+ fifo_read_tail_buffer(&wifi_spi_fifo, (uint8 *)receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+
+ if(strstr(receiver_buffer, wait_buffer))
+ {
+ return_state = 0;
+ break;
+ }
+ else if(strstr(receiver_buffer, "ERROR") || strstr(receiver_buffer, "busy"))
+ {
+ // 如果接收到报错或者模块忙 则跳出循环并且返回1
+ return_state = 1;
+ break;
+ }
+ }while(timeout --);
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 清除WiFi接收缓冲区内容
+// 参数说明 void
+// 返回参数 void
+// 使用示例 wifi_spi_clear_receive_buffer();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static void wifi_spi_clear_receive_buffer (void)
+{
+ // 清空WiFi接收缓冲区
+ fifo_clear(&wifi_spi_fifo);
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块数据解析
+// 参数说明 *target_buffer 目标存放地址指针 字符串数组
+// 参数说明 *origin_buffer 数据来源地址指针 字符串数组
+// 参数说明 start_char 起始提取字节 例如从 "1234" 中从 '2' 开始提取 就应该填入 '2'
+// 参数说明 end_char 结束提取字节 例如从 "1234" 中在 '4' 结束提取 就应该填入 '\0'(0x00 空字符 一般是字符串结尾)
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_data_parse(wifi_spi_information.mac, wifi_spi_receive_buffer, '"', '"'); // 调用获取本机mac地址后,调用此函数提取mac地址
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_data_parse (uint8 *target_buffer, uint8 *origin_buffer, char start_char, char end_char)
+{
+ uint8 return_state = 0;
+ char *location1;
+ char *location2;
+ location1 = strchr((char *)origin_buffer, start_char);
+ if(location1)
+ {
+ location1 ++;
+ location2 = strchr(location1, end_char);
+ if(location2)
+ {
+ memcpy(target_buffer, location1, location2-location1);
+ }
+ else
+ {
+ return_state = 1;
+ }
+ }
+ else
+ {
+ return_state = 1;
+ }
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查看模块版本信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_version();
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_version (void)
+{
+ char *location1;
+ uint8 return_state = 0;
+ uint8 receiver_buffer[256];
+ uint32 receiver_len = 256;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+GMR\r\n");
+ do
+ {
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ location1 = strrchr((char *)receiver_buffer, ':');
+ if(wifi_spi_data_parse(wifi_spi_information.version, (uint8 *)location1, ':', '('))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 模块回显设置
+// 参数说明 model 0:关闭模块的回写功能 其他:开启模块回写
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_echo_set("1");//开启模块回写功能
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_echo_set (char *model)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if('1' == *model)
+ {
+ wifi_spi_send_command("ATE1\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("ATE0\r\n");
+ }
+
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块自身 的 MAC 地址
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_mac()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_mac (void)
+{
+ uint8 return_state = 0;
+ uint8 receiver_buffer[64];
+ uint32 receiver_len = 64;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPAPMAC?\r\n");
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.mac, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块或者目标WIFI 的 IP 地址(取决于模块当前的工作模式)
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_ip()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_ip (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_STATION == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPSTA?\r\n");
+ }
+ else if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ wifi_spi_send_command("AT+CIPAP?\r\n");
+ }
+
+ do
+ {
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ if(wifi_spi_data_parse(wifi_spi_information.local_ip, receiver_buffer, '"', '"'))
+ {
+ return_state = 1;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 查询模块的相关信息
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 if(wifi_spi_get_information()){}
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_get_information (void)
+{
+ uint8 return_state = 0;
+ do
+ {
+ // 获取模块版本号
+ if(wifi_spi_get_version())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块IP地址
+ if(wifi_spi_get_ip())
+ {
+ return_state = 1;
+ break;
+ }
+ // 获取模块MAC信息
+ if(wifi_spi_get_mac())
+ {
+ return_state = 1;
+ break;
+ }
+ memcpy(wifi_spi_information.local_port, "no port", 7);
+ }while(0);
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 连接 WiFi
+// 参数说明 wifi_ssid WiFi名称
+// 参数说明 pass_word WiFi密码
+// 参数说明 model 0:查询WiFi连接情况 其他:连接WiFi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_get_or_connect_wifi("WiFi_name", "Pass_word", 1);
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_wifi (char *wifi_ssid, char *pass_word)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SOFTAP == wifi_spi_information.mode)
+ {
+ sprintf(temp, "AT+CWSAP=\"%s\",\"%s\",5,3\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ else
+ {
+ sprintf(temp, "AT+CWJAP=\"%s\",\"%s\"\r\n", wifi_ssid, pass_word);
+ wifi_spi_send_command(temp);
+ }
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 上电是否自动连接WiFi
+// 参数说明 model 0:上电不自动连接wifi 其他:上电自动连接wifi
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_auto_connect_wifi(0); //上电不自动连接wifi
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_auto_connect_wifi (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CWAUTOCONN=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置连接模式
+// 参数说明 model 0: 单连接模式 1:多连接模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_connect_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_connect_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMUX=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置传输模式
+// 参数说明 model – 0: 普通传输模式 IP断开后不重新连接
+// – 1: Wi-Fi 透传接收模式,仅支持 TCP 单连接、UDP 固定通信对端、SSL 单连接的情况 IP断开后会不断尝试重新连接
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_transfer_model("1");
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+static uint8 wifi_spi_set_transfer_model (char *model)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPMODE=%s\r\n", model);
+ wifi_spi_send_command(temp);
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 设置模块模式 (Station/SoftAP/Station+SoftAP)
+// 参数说明 state 0:无 Wi-Fi 模式,并且关闭 Wi-Fi RF----1: Station 模式----2: SoftAP 模式----3: SoftAP+Station 模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_set_model("1");
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_set_model (wifi_spi_mode_enum mode)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ if(WIFI_SPI_SOFTAP == mode)
+ {
+ wifi_spi_send_command("AT+CWMODE=2\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CWMODE=1\r\n");
+ }
+ // 设置模块工作模式
+ wifi_spi_information.mode = mode;
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 关闭睡眠模式
+// 参数说明 mode
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_close_sleep_model (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+SLEEP=0\r\n");
+ // 设置模块工作模式
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开与wifi的连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnected_wifi();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnected_wifi (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CWQAP\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 进入打开透传模式
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_entry_serianet();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_entry_serianet (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSEND\r\n");
+ return_state = wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 退出透传模式
+// 参数说明 model 0:关闭透传模式 其他:开启透传模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_exit_serianet(1);
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_exit_serianet (void)
+{
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ system_delay_ms(20);
+ wifi_spi_send_command("+++");
+ system_delay_ms(1000);
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立TCP连接
+// 参数说明 ip 远端 IPv4 地址、IPv6 地址,或域名
+// 参数说明 port 远端端口值
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_tcp_servers("192.168.101.110", "8080");
+// 备注信息 如果总是连接不上电脑的TCP服务器 可以尝试使用网线连接电脑
+// 如果是使用WiFi连接 可能会导致模块连接TCP服务器等待较长时间
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ sprintf(temp, "AT+CIPSTARTEX=\"TCP\",\"%s\",%s\r\n", ip, port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ // 设置传输模式
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_send_command("AT+CIPSTATE?\r\n");
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ break;
+ }
+ else
+ {
+ uint8 receiver_buffer[128];
+ uint32 receiver_len = 128;
+ fifo_read_buffer(&wifi_spi_fifo, receiver_buffer, &receiver_len, FIFO_READ_ONLY);
+ char* buffer_index = (char *)receiver_buffer;
+ char* end_index;
+
+ buffer_index += 22;
+ buffer_index += strlen(ip);
+ buffer_index += strlen(port);
+ end_index = strchr(buffer_index, ',');
+
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, buffer_index, (end_index - buffer_index));
+ }
+
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_TCP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 建立UDP连接
+// 参数说明 *ip 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 *port 远端端口值 字符串形式
+// 参数说明 *local_port 远端 IPv4 地址、IPv6 地址 或域名 字符串形式
+// 参数说明 mode 模块数据通信模式
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_connect_udp_client("192.168.101.110", "8080", "8080", WIFI_SPI_COMMAND);
+// 备注信息 自动分配ID
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode)
+{
+ char temp[64];
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(wifi_spi_set_connect_model("0"))
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ sprintf(temp, "AT+CIPSTARTEX=\"UDP\",\"%s\",%s,%s\r\n", ip, port, local_port);
+ wifi_spi_send_command(temp);
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(wifi_spi_set_transfer_model(WIFI_SPI_COMMAND == mode ? "0" : "1")) // 设置传输模式
+ {
+ return_state = 1;
+ break;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ if(WIFI_SPI_SERIANET == mode) // 透传模式下直接开启透传
+ {
+ if(wifi_spi_entry_serianet())
+ {
+ return_state = 1;
+ break;
+ }
+ }
+ memcpy(wifi_spi_information.local_port, " ", 7);
+ memcpy(wifi_spi_information.local_port, local_port, strlen(local_port));
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_ON;
+ wifi_spi_information.connect_mode = WIFI_SPI_UDP_CLIENT;
+ wifi_spi_information.transfer_mode = mode;
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 断开连接 TCP Server 使用本接口将会断开所有连接
+// 参数说明 void
+// 返回参数 uint8 0:成功 1:失败
+// 使用示例 wifi_spi_disconnect_link();
+// 备注信息
+//--------------------------------------------------------------------------------------------------
+uint8 wifi_spi_disconnect_link (void)
+{
+ uint8 return_state = 0;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ do
+ {
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ wifi_spi_send_command("AT+CIPCLOSE=5\r\n");
+ }
+ else
+ {
+ wifi_spi_send_command("AT+CIPCLOSE\r\n");
+ }
+
+ if(wifi_spi_wait_ack("OK", WAIT_TIME_OUT))
+ {
+ return_state = 1;
+ wifi_spi_information.connect_state = WIFI_SPI_SERVER_OFF;
+ break;
+ }
+ }while(0);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+
+ return return_state;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字节函数
+// 参数说明 data 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_byte(0xa5);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_byte (uint8 data)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = 1;
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(&data, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data(&data, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数
+// 参数说明 buff 需要发送的数据地址
+// 参数说明 len 发送长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_buffer("123", 3);
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 len)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ while(len)
+ {
+ if((WIFI_SPI_WRITE_MAX * 2) < len) send_length = WIFI_SPI_WRITE_MAX * 2;
+ else
+ {
+ send_length = (uint16)len;
+ }
+ len -= send_length;
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data(buff, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+ buff += send_length;
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ len = wifi_spi_write_data(buff, len);
+ }
+ }
+ }
+
+ return len;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送缓冲区函数(多个源地址)
+// 参数说明 *multi_buffer 多个源地址以及每个源地址需要发送的长度
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例
+// 备注信息 需要发送多个数组时,采用此函数可以极大的降低通讯时间,发送数据总长度不能超过4092
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer)
+{
+ uint8 i;
+ uint16 remain_length;
+
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ for(i = 0; i < WIFI_SPI_MAX_MULTI; i++)
+ {
+ if(multi_buffer->source[i]) wifi_spi_send_buffer(multi_buffer->source[i], multi_buffer->length[i]);
+ }
+ }
+ else
+ {
+ remain_length = (uint16)wifi_spi_write_data_multi(multi_buffer);
+ }
+ }
+ }
+
+ return remain_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi模块 发送字符串函数
+// 参数说明 *str 需要发送的数据
+// 返回参数 uint32 剩余未发送数据长度
+// 使用示例 wifi_spi_send_string("123");
+// 备注信息 当模块作为TCP服务器时,发送数据函数默认将数据发送至第一个连接模块的客户端
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_send_string (const char *str)
+{
+ char temp[64];
+ uint8 temp_length;
+ uint16 send_length;
+
+ send_length = (uint16)strlen(str);
+ if(wifi_spi_init_flag)
+ {
+ if(WIFI_SPI_SERVER_ON == wifi_spi_information.connect_state)
+ {
+ if(WIFI_SPI_COMMAND == wifi_spi_information.transfer_mode)
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ temp_length = (uint8)sprintf(temp, "AT+CIPSEND=");
+
+ if(WIFI_SPI_TCP_SERVER == wifi_spi_information.connect_mode)
+ {
+ temp_length += sprintf(&temp[temp_length], "0,");
+ }
+
+ temp_length += sprintf(&temp[temp_length], "%u\r\n", send_length);
+
+ wifi_spi_send_command(temp);
+ if(0 == wifi_spi_wait_ack("OK", WAIT_TIME_OUT)) // 等待模块响应
+ {
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_write_data((uint8 *)str, send_length);
+ wifi_spi_wait_ack("bytes", 50);
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ wifi_spi_wait_ack("OK", WAIT_TIME_OUT);
+ }
+
+ wifi_spi_clear_receive_buffer(); // 清空WiFi接收缓冲区
+ }
+ else
+ {
+ send_length = (uint16)wifi_spi_write_data((uint8 *)str, send_length);
+ }
+ }
+ }
+
+ return send_length;
+}
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块数据接收函数
+// 参数说明 buffer 接收数据的存放地址
+// 参数说明 len 数组长度,可直接填写或者使用sizeof求得
+// 返回参数 uint32 返回实际接收到的数据长度
+// 使用示例 uint8 test_buffer[256]; wifi_spi_read_buffer(&test_buffer[0], sizeof(test_buffer));
+// 备注信息
+//-------------------------------------------------------------------------------------------------------------------
+uint32 wifi_spi_read_buffer (uint8 *buffer, uint32 len)
+{
+ fifo_read_buffer(&wifi_spi_fifo, buffer, &len, FIFO_READ_AND_CLEAN);
+ return len;
+}
+
+//--------------------------------------------------------------------------------------------------
+// 函数简介 wifi spi handshake中断回调函数
+// 参数说明 void
+// 返回参数 void
+// 备注信息 内部调用
+//--------------------------------------------------------------------------------------------------
+void wifi_spi_callback (void)
+{
+ wifi_spi_check_state_read_buffer();
+ wifi_spi_ack_flag = 1; // ACK标志位置1
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------
+// 函数简介 WiFi 模块初始化
+// 参数说明 *wifi_ssid 目标连接的 WiFi 的名称 字符串形式
+// 参数说明 *pass_word 目标连接的 WiFi 的密码 字符串形式
+// 参数说明 wifi_mode 模块的工作模式 参照 zf_device_wireless_spi.h 中 wifi_spi_mode_enum 枚举
+// 返回参数 uint8 模块初始化状态 0-成功 1-错误
+// 使用示例 wifi_spi_init("SEEKFREE_2.4G", "SEEKFREEV2", WIFI_UART_STATION);
+// 备注信息 初始化会首先设置串口配置,之后会对模块进行基本参数配置
+// 具体的配置信息可以在 zf_device_wireless_spi.h 文件中修改
+//-------------------------------------------------------------------------------------------------------------------
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode)
+{
+ uint8 return_state = 0;
+ uint32 temp_isr;
+
+ spi_init(WIFI_SPI_INDEX, SPI_MODE0, WIFI_SPI_SPEED, WIFI_SPI_SCK_PIN, WIFI_SPI_MOSI_PIN, WIFI_SPI_MISO_PIN, SPI_CS_NULL);//硬件SPI初始化
+ set_wireless_type(WIFI_SPI, wifi_spi_callback);
+ fifo_init(&wifi_spi_fifo, FIFO_DATA_8BIT, wifi_spi_buffer, WIFI_SPI_BUFFER_SIZE);
+
+ gpio_init(WIFI_SPI_CS_PIN, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(WIFI_SPI_RST_PIN, GPO, 1, GPO_PUSH_PULL);
+
+ temp_isr = interrupt_global_disable();
+
+ exti_init(WIFI_SPI_INT_PIN, EXTI_TRIGGER_RISING);
+
+ gpio_set_level(WIFI_SPI_RST_PIN, 0);
+ system_delay_ms(50);
+ gpio_set_level(WIFI_SPI_RST_PIN, 1);
+ system_delay_ms(1000);
+
+ exti_flag_clear(WIFI_SPI_INT_PIN);
+
+ interrupt_global_enable(temp_isr);
+ do
+ {
+ if(wifi_spi_echo_set("0")) // 关闭模块回写
+ {
+ zf_log(0, "exit echo failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_auto_connect_wifi("0")) // 关闭自动连接
+ {
+ zf_log(0, "close auto connect failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_model(wifi_mode)) // 设置运行模式
+ {
+ zf_log(0, "set run mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_close_sleep_model()) // 关闭睡眠模式
+ {
+ zf_log(0, "set sleep mode failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_set_wifi((char *)wifi_ssid, (char *)pass_word)) // 连接 wifi 或者开启热点
+ {
+ zf_log(0, "wifi set failed");
+ return_state = 1;
+ break;
+ }
+
+ if(wifi_spi_get_information()) // 模块基本参数获取
+ {
+ zf_log(0, "get module information failed");
+ return_state = 1;
+ break;
+ }
+#if WIFI_SPI_AUTO_CONNECT == 1
+ if(wifi_spi_connect_tcp_servers(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_SERIANET)) // 连接TCP服务器
+ {
+ zf_log(0, "connect TCP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+#if WIFI_SPI_AUTO_CONNECT == 2
+ if(wifi_spi_connect_udp_client(WIFI_SPI_TARGET_IP, WIFI_SPI_TARGET_PORT, WIFI_SPI_LOCAL_PORT, WIFI_SPI_SERIANET)) // 建立UDP连接
+ {
+ zf_log(0, "connect UDP server failed");
+ return_state = 1;
+ break;
+ }
+#endif
+ // 模块初始化成功
+ wifi_spi_init_flag = 1;
+ }while(0);
+
+ return return_state;
+}
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_spi.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_spi.h
new file mode 100644
index 0000000..5e5a025
--- /dev/null
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_spi.h
@@ -0,0 +1,180 @@
+/*********************************************************************************************************************
+* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
+* Copyright (c) 2022 SEEKFREE 逐飞科技
+*
+* 本文件是 TC264 开源库的一部分
+*
+* TC264 开源库 是免费软件
+* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
+* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+*
+* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+* 甚至没有隐含的适销性或适合特定用途的保证
+* 更多细节请参见 GPL
+*
+* 您应该在收到本开源库的同时收到一份 GPL 的副本
+* 如果没有,请参阅
+*
+* 额外注明:
+* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+*
+* 文件名称 zf_device_wifi_spi
+* 公司名称 成都逐飞科技有限公司
+* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+* 开发环境 ADS v1.9.4
+* 适用平台 TC264D
+* 店铺链接 https://seekfree.taobao.com/
+*
+* 修改记录
+* 日期 作者 备注
+* 2023-05-27 pudding first version
+********************************************************************************************************************/
+/*********************************************************************************************************************
+* 接线定义:
+* ------------------------------------
+* 模块管脚 单片机管脚
+* RST 查看 zf_device_wifi_spi.h 中 WIFI_SPI_RST_PIN 宏定义
+* INT 查看 zf_device_wifi_spi.h 中 WIFI_SPI_INT_PIN 宏定义
+* CS 查看 zf_device_wifi_spi.h 中 WIFI_SPI_CS_PIN 宏定义
+* MISO 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MISO_PIN 宏定义
+* SCK 查看 zf_device_wifi_spi.h 中 WIFI_SPI_SCK_PIN 宏定义
+* MOSI 查看 zf_device_wifi_spi.h 中 WIFI_SPI_MOSI_PIN 宏定义
+* 5V 5V 电源
+* GND 电源地
+* 其余引脚悬空
+* ------------------------------------
+*********************************************************************************************************************/
+
+#ifndef _zf_device_wifi_spi_h
+#define _zf_device_wifi_spi_h
+
+#include "zf_common_typedef.h"
+
+#define WIFI_SPI_INDEX (SPI_3 ) // 定义使用的SPI号
+#define WIFI_SPI_SPEED (30 * 1000 * 1000 ) // 硬件 SPI 速率
+#define WIFI_SPI_SCK_PIN (SPI3_SCLK_P22_3 ) // 定义SPI_SCK引脚
+#define WIFI_SPI_MOSI_PIN (SPI3_MOSI_P22_0 ) // 定义SPI_MOSI引脚
+#define WIFI_SPI_MISO_PIN (SPI3_MISO_P22_1 ) // 定义SPI_MISO引脚 IPS没有MISO引脚,但是这里任然需要定义,在spi的初始化时需要使用
+#define WIFI_SPI_CS_PIN (P22_2 ) // 定义SPI_CS引脚 采用软件CS引脚
+#define WIFI_SPI_INT_PIN (ERU_CH5_REQ1_P15_8) // 定义中断引脚
+#define WIFI_SPI_RST_PIN (P23_1 ) // 定义复位引脚
+
+
+#define WIFI_SPI_BUFFER_SIZE (1024) // 定义SPI接收的缓冲区大小
+
+#define WIFI_SPI_AUTO_CONNECT (0) // 定义是否初始化时建立TCP或者UDP连接 0-不连接 1-自动连接TCP服务器并进入透传模式 2-自动连接UDP服务器并进入透传模式 3:自动建立TCP服务器
+
+#if (WIFI_SPI_AUTO_CONNECT > 2)
+#error "WIFI_SPI_AUTO_CONNECT 的值只能为 [0,1,2]"
+#else
+#define WIFI_SPI_TARGET_IP "192.168.2.28" // 连接目标的 IP
+#define WIFI_SPI_TARGET_PORT "8080" // 连接目标的端口
+#define WIFI_SPI_LOCAL_PORT "8080" // 本机端口
+#endif
+
+#define WIFI_SPI_MAX_MULTI (17) // 多地址发送,最大8个地址
+
+typedef enum
+{
+ BUFFER_IDLE, // 模块的缓冲区是空闲的
+ BUFFER_READ, // 模块的缓冲区有数据需要读取
+ BUFFER_WRITE, // 模块的缓冲区是可写的
+}wifi_spi_buffer_state_enum;
+
+typedef enum
+{
+ TRANSMIT_IDLE, // 当前没有传输
+ TRANSMIT_WRITE_REQUEST, // 给模块发送了一个传输请求
+ TRANSMIT_READ_STATE, // 读取模块状态
+ TRANSMIT_READ, // 正在读取模块内部数据
+ TRANSMIT_WRITE, // 正在往模块写入数据
+}wifi_spi_transmit_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_STATION, // 设备模式
+ WIFI_SPI_SOFTAP, // AP模式
+}wifi_spi_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_COMMAND, // 使用命令的方式发送数据
+ WIFI_SPI_SERIANET, // 使用透传的方式发送数据
+}wifi_spi_transfer_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_TCP_CLIENT, // 模块连接TCP服务器
+ WIFI_SPI_TCP_SERVER, // 模块作为TCP服务器
+ WIFI_SPI_UDP_CLIENT, // 模块启用UDP连接
+}wifi_spi_connect_mode_enum;
+
+typedef enum
+{
+ WIFI_SPI_SERVER_OFF, // 模块未连接服务器
+ WIFI_SPI_SERVER_ON, // 模块已经连接服务器
+}wifi_spi_connect_state_enum;
+
+typedef enum
+{
+ WIFI_SPI_LINK_0, // 模块当前链接 0
+ WIFI_SPI_LINK_1, // 模块当前链接 1
+ WIFI_SPI_LINK_2, // 模块当前链接 2
+ WIFI_SPI_LINK_3, // 模块当前链接 3
+ WIFI_SPI_LINK_4, // 模块当前链接 4
+}wifi_spi_link_id_enum;
+
+typedef struct
+{
+ uint8 reserve;
+ uint8 cmd;
+ uint8 addr;
+ uint8 dummy;
+ uint8 magic;
+ uint8 sequence;
+ uint16 length;
+}wifi_spi_buffer_struct;
+
+typedef struct
+{
+ uint8 version[12]; // 固件版本 字符串形式
+ uint8 mac[20]; // 本机 MAC 地址 字符串形式
+ uint8 local_ip[17]; // 本机 IP 地址 字符串形式
+ uint8 local_port[10]; // 本机端口号 字符串形式
+ uint8 remote_ip[5][17]; // 远端 IP 地址 字符串形式
+ wifi_spi_mode_enum mode; // WIFI 模式
+ wifi_spi_transfer_mode_enum transfer_mode; // 当前传输模式
+ wifi_spi_connect_mode_enum connect_mode; // 网络连接模式
+ wifi_spi_connect_state_enum connect_state; // 服务器连接情况
+}wifi_spi_information_struct;
+
+typedef struct
+{
+ uint8 *source[WIFI_SPI_MAX_MULTI];
+ uint16 length[WIFI_SPI_MAX_MULTI];
+}wifi_spi_send_multi_struct;
+
+extern wifi_spi_information_struct wifi_spi_information;
+
+
+uint8 wifi_spi_disconnected_wifi (void); // 断开 WIFI 连接
+uint8 wifi_spi_entry_serianet (void); // 打开透传模式
+uint8 wifi_spi_exit_serianet (void); // 关闭透传模式
+
+uint8 wifi_spi_connect_tcp_servers (char *ip, char *port, wifi_spi_transfer_mode_enum mode); // 建立 TCP 连接
+uint8 wifi_spi_connect_udp_client (char *ip, char *port, char *local_port, wifi_spi_transfer_mode_enum mode); // 建立 UDP 传输
+uint8 wifi_spi_disconnect_link (void); // 断开连接 TCP Server 使用本接口将会断开所有连接
+
+uint32 wifi_spi_send_byte (uint8 data); // WIFI 模块发送字节函数
+uint32 wifi_spi_send_buffer (const uint8 *buff, uint32 length); // WIFI 模块发送缓冲区函数
+uint32 wifi_spi_send_buffer_multi (wifi_spi_send_multi_struct *multi_buffer); // WIFI 模块发送多缓冲区函数
+uint32 wifi_spi_send_string (const char *str); // WIFI 模块发送字符串函数
+
+uint32 wifi_spi_read_buffer (uint8 *buff, uint32 len); // WIFI 模块数据接收函数
+
+uint8 wifi_spi_init (char *wifi_ssid, char *pass_word, wifi_spi_mode_enum wifi_mode); // WIFI 模块初始化函数
+
+#endif
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_uart.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_uart.c
index 10b5b94..2f66c33 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_uart.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_uart.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_uart.h
index 6be4bf5..abcb253 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_uart.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wifi_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wifi_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wireless_uart.c b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wireless_uart.c
index 233ebf4..5535770 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wireless_uart.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wireless_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wireless_uart.h b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wireless_uart.h
index a5db840..2418545 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wireless_uart.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_device/zf_device_wireless_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_device_wireless_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_adc.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_adc.c
index a8c48b9..9a262a1 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_adc.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_adc.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_adc.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_adc.h
index 4159205..378b67e 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_adc.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_adc.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_adc
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_delay.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_delay.c
index bc8d470..737e267 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_delay.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_delay.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_delay.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_delay.h
index 4987caa..6802ec8 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_delay.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_delay.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_delay
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_dma.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_dma.c
index 646f03a..04b0f26 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_dma.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_dma.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_dma.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_dma.h
index 7a9e923..1ec555b 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_dma.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_dma.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_dma
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_encoder.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_encoder.c
index 8ac76d5..6592198 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_encoder.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_encoder.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_encoder.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_encoder.h
index 451e142..68d159f 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_encoder.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_encoder.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_encoder
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_exti.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_exti.c
index a457edc..72c9a1f 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_exti.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_exti.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_exti.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_exti.h
index bcbc456..30f5ef6 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_exti.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_exti.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_exti
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_flash.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_flash.c
index 94e306e..f1d74d0 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_flash.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_flash.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_flash.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_flash.h
index 487be42..0df532a 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_flash.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_flash.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_flash
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_gpio.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_gpio.c
index 4388646..5071114 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_gpio.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_gpio.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_gpio.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_gpio.h
index 753635e..2b23be0 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_gpio.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_gpio.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_gpio
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pit.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pit.c
index deea36c..9c2c1d3 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pit.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pit.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pit.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pit.h
index 664fabd..5461e05 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pit.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pit.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pit
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pwm.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pwm.c
index e2f4e12..ad1059a 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pwm.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pwm.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pwm.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pwm.h
index 1b76925..d6dce78 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pwm.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_pwm.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_pwm
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_iic.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_iic.c
index 54b0f4d..9833b62 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_iic.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_iic.c
@@ -24,13 +24,14 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
+* 2022-07-06 pudding 修复 soft_iic transfer 函数读取长度为 0 时发送 restart 信号的 bug
********************************************************************************************************************/
#include "zf_common_debug.h"
@@ -568,13 +569,17 @@ void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uin
{
soft_iic_send_data(soft_iic_obj, *write_data ++);
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data ++ = soft_iic_read_data(soft_iic_obj, read_len == 0);
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data ++ = soft_iic_read_data(soft_iic_obj, 0 == read_len);
+ }
}
soft_iic_stop(soft_iic_obj);
+
}
//-------------------------------------------------------------------------------------------------------------------
@@ -597,13 +602,16 @@ void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const ui
soft_iic_send_data(soft_iic_obj, (uint8)((*write_data & 0xFF00) >> 8));
soft_iic_send_data(soft_iic_obj, (uint8)(*write_data ++ & 0x00FF));
}
- soft_iic_start(soft_iic_obj);
- soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
- while(read_len --)
+ if(read_len)
{
- *read_data = soft_iic_read_data(soft_iic_obj, 0);
- *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, read_len == 0));
- read_data ++;
+ soft_iic_start(soft_iic_obj);
+ soft_iic_send_data(soft_iic_obj, soft_iic_obj->addr << 1 | 0x01);
+ while(read_len --)
+ {
+ *read_data = soft_iic_read_data(soft_iic_obj, 0);
+ *read_data = ((*read_data << 8)| soft_iic_read_data(soft_iic_obj, 0 == read_len));
+ read_data ++;
+ }
}
soft_iic_stop(soft_iic_obj);
}
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_iic.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_iic.h
index 65d239f..6226320 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_iic.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_iic.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_iic
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -74,6 +74,9 @@ void soft_iic_read_8bit_registers (soft_iic_info_struct *soft_iic_obj,
uint16 soft_iic_read_16bit_register (soft_iic_info_struct *soft_iic_obj, const uint16 register_name);
void soft_iic_read_16bit_registers (soft_iic_info_struct *soft_iic_obj, const uint16 register_name, uint16 *data, uint32 len);
+void soft_iic_transfer_8bit_array (soft_iic_info_struct *soft_iic_obj, const uint8 *write_data, uint32 write_len, uint8 *read_data, uint32 read_len);
+void soft_iic_transfer_16bit_array (soft_iic_info_struct *soft_iic_obj, const uint16 *write_data, uint32 write_len, uint16 *read_data, uint32 read_len);
+
void soft_iic_sccb_write_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name, uint8 data);
uint8 soft_iic_sccb_read_register (soft_iic_info_struct *soft_iic_obj, const uint8 register_name);
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_spi.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_spi.c
index a854e4e..292c60b 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_spi.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_spi.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_spi.h
index 9b06fc5..6a9c207 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_spi.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_soft_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_soft_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_spi.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_spi.c
index 09266aa..1b99196 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_spi.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_spi.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_spi.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_spi.h
index a17adc7..e73507e 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_spi.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_spi.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_spi
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_timer.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_timer.c
index 4fd8cd4..a953b92 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_timer.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_timer.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_timer.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_timer.h
index 9ee2b86..3c86f58 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_timer.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_timer.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_timer
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_uart.c b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_uart.c
index 170771d..2173b99 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_uart.c
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_uart.c
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_uart.h b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_uart.h
index 0fe4a9b..fd17caa 100644
--- a/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_uart.h
+++ b/Seekfree_TC264_Opensource_Library/libraries/zf_driver/zf_driver_uart.h
@@ -24,7 +24,7 @@
* 文件名称 zf_driver_uart
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/user/cpu0_main.c b/Seekfree_TC264_Opensource_Library/user/cpu0_main.c
index d6ecb49..c3b4911 100644
--- a/Seekfree_TC264_Opensource_Library/user/cpu0_main.c
+++ b/Seekfree_TC264_Opensource_Library/user/cpu0_main.c
@@ -24,7 +24,7 @@
* 文件名称 cpu0_main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -50,6 +50,7 @@
// 本例程是开源库移植用空工程
// **************************** 代码区域 ****************************
+
int core0_main(void)
{
clock_init(); // 获取时钟频率<务必保留>
@@ -66,6 +67,7 @@ int core0_main(void)
+
// 此处编写需要循环执行的代码
}
}
diff --git a/Seekfree_TC264_Opensource_Library/user/cpu1_main.c b/Seekfree_TC264_Opensource_Library/user/cpu1_main.c
index 1fad39d..f256a93 100644
--- a/Seekfree_TC264_Opensource_Library/user/cpu1_main.c
+++ b/Seekfree_TC264_Opensource_Library/user/cpu1_main.c
@@ -24,7 +24,7 @@
* 文件名称 cpu1_main
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/user/isr.c b/Seekfree_TC264_Opensource_Library/user/isr.c
index be4734c..de920c4 100644
--- a/Seekfree_TC264_Opensource_Library/user/isr.c
+++ b/Seekfree_TC264_Opensource_Library/user/isr.c
@@ -24,7 +24,7 @@
* 文件名称 isr
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
@@ -43,6 +43,7 @@ IFX_INTERRUPT(cc60_pit_ch0_isr, 0, CCU6_0_CH0_ISR_PRIORITY)
pit_clear_flag(CCU60_CH0);
+
}
@@ -101,11 +102,12 @@ IFX_INTERRUPT(exti_ch0_ch4_isr, 0, EXTI_CH0_CH4_INT_PRIO)
IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
interrupt_global_enable(0); // 开启中断嵌套
+
if(exti_flag_get(ERU_CH1_REQ10_P14_3)) // 通道1中断
{
exti_flag_clear(ERU_CH1_REQ10_P14_3);
-
+ tof_module_exti_handler(); // ToF 模块 INT 更新中断
}
@@ -113,6 +115,7 @@ IFX_INTERRUPT(exti_ch1_ch5_isr, 0, EXTI_CH1_CH5_INT_PRIO)
{
exti_flag_clear(ERU_CH5_REQ1_P15_8);
+ wireless_module_spi_handler(); // SPI WIFI 中断回调函数
}
}
diff --git a/Seekfree_TC264_Opensource_Library/user/isr.h b/Seekfree_TC264_Opensource_Library/user/isr.h
index 14367d3..b22cd26 100644
--- a/Seekfree_TC264_Opensource_Library/user/isr.h
+++ b/Seekfree_TC264_Opensource_Library/user/isr.h
@@ -24,7 +24,7 @@
* 文件名称 isr
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
diff --git a/Seekfree_TC264_Opensource_Library/user/isr_config.h b/Seekfree_TC264_Opensource_Library/user/isr_config.h
index ce77b6b..1776039 100644
--- a/Seekfree_TC264_Opensource_Library/user/isr_config.h
+++ b/Seekfree_TC264_Opensource_Library/user/isr_config.h
@@ -24,7 +24,7 @@
* 文件名称 isr_config
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 ADS v1.8.0
+* 开发环境 ADS v1.9.4
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*