Initial commit: TC264 smart car project with IPS200 menu system

- IPS200 display menu with real-time status and parameter settings
- Camera image processing and line tracking
- IMU attitude solution and PID control
- WiFi SPI oscilloscope data transmission
This commit is contained in:
32343 committed 2026-05-10 21:38:49 +08:00
commit 843447835d
660 files changed
+443632

No files matched your search

+134
View File
@@ -0,0 +1,134 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2023-04-26 pudding 新增初始化完成标志等待操作,需要等待CPU0初始化完成后其他CPU才能进行赋值
********************************************************************************************************************/
#include "IfxScuEru.h"
#include "Ifxstm.h"
#include "Cpu0_Main.h"
#include "Cpu/Std/IfxCpu.h"
#include "zf_driver_delay.h"
#include "zf_common_interrupt.h"
#include "zf_common_clock.h"
App_Cpu0 g_AppCpu0; // 频率信息变量
static vuint8 cpu_init_finish[IfxCpu_Id_none]; // 核心初始化完成标志位
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 设置系统频率
// 返回类型 void
// 使用示例 set_clock();
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void set_clock (void)
{
IfxScuCcu_setCpuFrequency(IfxCpu_ResourceCpu_0, (float32)AURIX_MCU_FREQUENCY);
IfxScuCcu_setCpuFrequency(IfxCpu_ResourceCpu_1, (float32)AURIX_MCU_FREQUENCY);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 获取系统频率
// 返回类型 void
// 使用示例 get_clock();
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void get_clock (void)
{
// 获取时钟频率,便于查看当前系统运行频率
g_AppCpu0.info.pllFreq = IfxScuCcu_getPllFrequency();
g_AppCpu0.info.cpuFreq = IfxScuCcu_getCpuFrequency(IfxCpu_getCoreIndex());
g_AppCpu0.info.sysFreq = IfxScuCcu_getSpbFrequency();
g_AppCpu0.info.stmFreq = IfxStm_getFrequency(&MODULE_STM0);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 关闭看门狗
// 返回类型 void
// 使用示例 disable_Watchdog();
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void disable_Watchdog (void)
{
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 时钟初始化
// 返回类型 void
// 使用示例 clock_init();
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void clock_init (void)
{
interrupt_global_disable(); // 关闭总中断
disable_Watchdog(); // 关闭看门狗
get_clock(); // 获取系统频率
system_delay_init(); // 延时函数初始化
interrupt_global_enable(0); // 打开全局中断
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 等待所有核心初始化完毕
// 返回类型 void
// 使用示例 cpu_wait_event_ready();
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void cpu_wait_event_ready (void)
{
uint8 i;
uint8 all_cpu_init_finish;
if(IfxCpu_getCoreId() != 0)
{
while(cpu_init_finish[0] == 0);
}
// 调用此函数的核心初始化完毕,标志位置一
cpu_init_finish[IfxCpu_getCoreId()] = 1;
// 等待其他核心初始化完毕
do
{
all_cpu_init_finish = 1;
for(i = 0; i < IfxCpu_Id_none; i++)
{
all_cpu_init_finish *= cpu_init_finish[i];
}
system_delay_ms(1);
}while(0 == all_cpu_init_finish);
}
+48
View File
@@ -0,0 +1,48 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_clock
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
********************************************************************************************************************/
#ifndef _zf_common_clock_h_
#define _zf_common_clock_h_
#include "zf_common_typedef.h"
#define AURIX_MCU_FREQUENCY (200*1000*1000) // 设置单片机频率为200M 200M(默认频率)
void set_clock (void); // 设置系统频率
void get_clock (void); // 获取系统频率
void disable_Watchdog (void); // 关闭看门狗
void clock_init (void); // 时钟初始化
void cpu_wait_event_ready (void); // 等待所有核心初始化完毕
#endif
+423
View File
@@ -0,0 +1,423 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
* 2022-05-26 pudding 新增调试串口发送函数
********************************************************************************************************************/
#include "zf_common_interrupt.h"
#include "zf_common_fifo.h"
#include "zf_driver_uart.h"
#include "zf_common_debug.h"
static debug_output_struct debug_output_info;
static volatile uint8 zf_debug_init_flag = 0;
static volatile uint8 zf_debug_assert_enable = 1;
#if DEBUG_UART_USE_INTERRUPT // 如果启用 debug uart 接收中断
uint8 debug_uart_buffer[DEBUG_RING_BUFFER_LEN]; // 数据存放数组
uint8 debug_uart_data;
fifo_struct debug_uart_fifo;
#endif
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 软延时函数 在 200MHz 下是一秒多的时间 各单片机需要根据各自时钟试验
// 参数说明 void
// 返回参数 void
// 使用示例 debug_delay();
// 备注信息 本函数在文件内部调用 用户不用关注 也不可修改
//-------------------------------------------------------------------------------------------------------------------
static void debug_delay (void)
{
vuint32 loop_1 = 0, loop_2 = 0;
for(loop_1 = 0; loop_1 <= 0xFFF; loop_1 ++)
for(loop_2 = 0; loop_2 <= 0x1FFF; loop_2 ++);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 串口输出接口
// 参数说明 *str 需要输出的字符串
// 返回参数 void
// 使用示例 debug_uart_str_output("Log message");
// 备注信息 本函数在文件内部调用 用户不用关注 也不可修改
//-------------------------------------------------------------------------------------------------------------------
static void debug_uart_str_output (const char *str)
{
uart_write_string(DEBUG_UART_INDEX, str);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 输出接口
// 参数说明 *type log 类型
// 参数说明 *file 文件名
// 参数说明 line 目标行数
// 参数说明 *str 信息
// 返回参数 void
// 使用示例 debug_output("Log message", file, line, str);
// 备注信息 本函数在文件内部调用 用户不用关注 也不可修改
//-------------------------------------------------------------------------------------------------------------------
static void debug_output (char *type, char *file, int line, char *str)
{
char *file_str;
vuint16 i = 0, j = 0;
vint32 len_origin = 0;
vint16 show_len = 0;
vint16 show_line_index = 0;
len_origin = strlen(file);
char output_buffer[256];
char file_path_buffer[64];
if(debug_output_info.type_index)
{
debug_output_info.output_screen_clear();
}
if(zf_debug_init_flag)
{
if(debug_output_info.type_index)
{
// 需要分行将文件的路径和行数输出
// <不输出完整路径 只输出一级目录 例如 src/main.c>
// 输出 line : xxxx
debug_output_info.output_screen(0, show_line_index ++, type);
file_str = file;
len_origin = strlen(file);
show_len = (debug_output_info.display_x_max / debug_output_info.font_x_size);
while(*file_str++ != '\0');
// 只取一级目录 如果文件放在盘符根目录 或者 MDK 的工程根目录 就会直接输出当前目录
for(j = 0; (j < 2) && (len_origin >= 0); len_origin --) // 查找两个 '/'
{
file_str --;
if((*file_str == '/') || (*file_str == 0x5C))
{
j ++;
}
}
// 文件路径保存到数组中
if(len_origin >= 0)
{
file_str ++;
sprintf(output_buffer, "file: %s", file_str);
}
else
{
if(0 == j)
{
sprintf(output_buffer, "file: mdk/%s", file_str);
}
else
{
sprintf(output_buffer, "file: %s", file_str);
}
}
// 屏幕显示路径
for(i = 0; i < ((strlen(output_buffer) / show_len) + 1); i ++)
{
for(j = 0; j < show_len; j ++)
{
if(strlen(output_buffer) < (j + i * show_len))
{
break;
}
file_path_buffer[j] = output_buffer[j + i * show_len];
}
file_path_buffer[j] = '\0'; // 末尾添加\0
debug_output_info.output_screen(0, debug_output_info.font_y_size * show_line_index ++, file_path_buffer);
}
// 屏幕显示行号
sprintf(output_buffer, "line: %d", line);
debug_output_info.output_screen(0, debug_output_info.font_y_size * show_line_index ++, output_buffer);
// 屏幕显示 Log 如果有的话
if(NULL != str)
{
for(i = 0; i < ((strlen(str) / show_len) + 1); i ++)
{
for(j = 0; j < show_len; j ++)
{
if(strlen(str) < (j + i * show_len))
{
break;
}
file_path_buffer[j] = str[j + i * show_len];
}
file_path_buffer[j] = '\0'; // 末尾添加\0
debug_output_info.output_screen(0, debug_output_info.font_y_size * show_line_index ++, file_path_buffer);
}
}
}
else
{
char output_buffer[256];
memset(output_buffer, 0, 256);
debug_output_info.output_uart(type);
if(NULL != str)
{
sprintf(output_buffer, "\r\nfile %s line %d: %s.\r\n", file, line, str);
}
else
{
sprintf(output_buffer, "\r\nfile %s line %d.\r\n", file, line);
}
debug_output_info.output_uart(output_buffer);
}
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 调试串口发送缓冲区
// 参数说明 *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 环形缓冲区数据
// 参数说明 *buff 读出数据存放的数组指针
// 参数说明 len 需要读取的长度
// 返回参数 uint32 读出数据的实际长度
// 使用示例
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
//-------------------------------------------------------------------------------------------------------------------
uint32 debug_read_ring_buffer (uint8 *buff, uint32 len)
{
fifo_read_buffer(&debug_uart_fifo, buff, &len, FIFO_READ_AND_CLEAN);
return len;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 串口中断处理函数 isr.c 中对应串口中断服务函数调用
// 参数说明 void
// 返回参数 void
// 使用示例 debug_interrupr_handler();
// 备注信息 本函数需要开启 DEBUG_UART_USE_INTERRUPT 宏定义才可使用
// 并且本函数默认放置在 UART1 的串口接收中断处理处
//-------------------------------------------------------------------------------------------------------------------
void debug_interrupr_handler (void)
{
if(zf_debug_init_flag)
{
uart_query_byte(DEBUG_UART_INDEX, &debug_uart_data); // 读取串口数据
fifo_write_buffer(&debug_uart_fifo, &debug_uart_data, 1); // 存入 FIFO
}
}
#endif
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 启用断言
// 参数说明 void
// 返回参数 void
// 使用示例 debug_assert_enable();
// 备注信息 断言默认开启 建议开启断言
//-------------------------------------------------------------------------------------------------------------------
void debug_assert_enable (void)
{
zf_debug_assert_enable = 1;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 禁用断言
// 参数说明 void
// 返回参数 void
// 使用示例 debug_assert_disable();
// 备注信息 断言默认开启 不建议禁用断言
//-------------------------------------------------------------------------------------------------------------------
void debug_assert_disable (void)
{
zf_debug_assert_enable = 0;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 断言处理函数
// 参数说明 pass 判断是否触发断言
// 参数说明 *file 文件名
// 参数说明 line 目标行数
// 返回参数 void
// 使用示例 zf_assert(0);
// 备注信息 这个函数不是直接调用的 此部分不允许用户更改
// 使用 zf_commmon_debug.h 中的 zf_assert(x) 接口
//-------------------------------------------------------------------------------------------------------------------
void debug_assert_handler (uint8 pass, char *file, int line)
{
if(pass || !zf_debug_assert_enable)
{
return;
}
static uint8 assert_nest_index = 0;
if(0 != assert_nest_index)
{
while(TRUE);
}
assert_nest_index ++;
assert_interrupt_config();
while(TRUE)
{
// 如果代码跳转到这里停住了
// 一般你的函数参数传递出错了
// 或者你自己调用的 zf_assert(x) 接口处报错了
// 如果调用了 debug_init 初始化了 log 输出
// 就在对应串口输出去查看是哪个文件的哪一行报错
// 如果没有初始化 debug
// 那就看看这个 file 的字符串值和 line 的行数
// 那代表报错的文件路径名称和对应报错行数
// 再去调试看看是为什么参数出错
debug_output("Assert error", file, line, NULL);
debug_delay();
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 调试信息处理函数
// 参数说明 pass 判断是否触发断言
// 参数说明 *str 输出的信息
// 参数说明 *file 文件名
// 参数说明 line 目标行数
// 返回参数 void
// 使用示例 zf_log(0, "Log Message");
// 备注信息 这个函数不是直接调用的 此部分不允许用户更改
// 使用 zf_commmon_debug.h 中的 zf_log(x, str) 接口
//-------------------------------------------------------------------------------------------------------------------
void debug_log_handler (uint8 pass, char *str, char *file, int line)
{
if(pass)
{
return;
}
if(zf_debug_init_flag)
{
debug_output("Log message", file, line, str);
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 输出绑定信息初始化
// 参数说明 *info debug 输出的信息结构体
// 返回参数 void
// 使用示例 debug_output_struct_init(info);
// 备注信息 这个函数一般不由用户调用
//-------------------------------------------------------------------------------------------------------------------
void debug_output_struct_init (debug_output_struct *info)
{
info->type_index = 0; // 屏幕信息输出标志
info->display_x_max = 0xFFFF; // 屏幕显示X轴最大值
info->display_y_max = 0xFFFF; // 屏幕显示Y轴最大值
info->font_x_size = 0xFF; // 字体X轴最大值
info->font_y_size = 0xFF; // 字体Y轴最大值
info->output_uart = NULL; // 输出调试信息的串口
info->output_screen = NULL; // 输出调试信息的屏幕
info->output_screen_clear = NULL; // 屏幕清屏
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 输出绑定初始化
// 参数说明 *info debug 输出的信息结构体
// 返回参数 void
// 使用示例 debug_output_init(info);
// 备注信息 这个函数一般不由用户调用
//-------------------------------------------------------------------------------------------------------------------
void debug_output_init (debug_output_struct *info)
{
debug_output_info.type_index = info->type_index;
debug_output_info.display_x_max = info->display_x_max;
debug_output_info.display_y_max = info->display_y_max;
debug_output_info.font_x_size = info->font_x_size;
debug_output_info.font_y_size = info->font_y_size;
debug_output_info.output_uart = info->output_uart;
debug_output_info.output_screen = info->output_screen;
debug_output_info.output_screen_clear = info->output_screen_clear;
zf_debug_init_flag = 1;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 debug 串口初始化
// 参数说明 void
// 返回参数 void
// 使用示例 debug_init();
// 备注信息 开源库示例默认调用 但默认禁用中断接收
//-------------------------------------------------------------------------------------------------------------------
void debug_init (void)
{
debug_output_struct info; // 声明调试信息结构体
debug_output_struct_init(&info); // 初始化断言调试信息
info.output_uart = debug_uart_str_output; // 配置断言输出串口
debug_output_init(&info);
uart_init(DEBUG_UART_INDEX, // 在 zf_common_debug.h 中查看对应值
DEBUG_UART_BAUDRATE, // 在 zf_common_debug.h 中查看对应值
DEBUG_UART_TX_PIN, // 在 zf_common_debug.h 中查看对应值
DEBUG_UART_RX_PIN); // 在 zf_common_debug.h 中查看对应值
#if DEBUG_UART_USE_INTERRUPT // 条件编译 只有在启用串口中断才编译
fifo_init(&debug_uart_fifo, FIFO_DATA_8BIT, debug_uart_buffer, DEBUG_RING_BUFFER_LEN);
uart_rx_interrupt(DEBUG_UART_INDEX, 1); // 使能对应串口接收中断
#endif
}
+119
View File
@@ -0,0 +1,119 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_debug
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 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 (1) // 是否启用 debug uart 接收中断
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 断言
// 参数说明 x 判断是否触发断言 0-触发断言 1-不触发断言
// 返回参数 void
// 使用示例 zf_assert(0);
// 备注信息 一般用于参数判断 zf_assert(0) 就断言报错
// 默认情况下会在 Debug UART 输出
// 但如果使用开源库内屏幕接口初始化了屏幕 则会在屏幕上显示
//-------------------------------------------------------------------------------------------------------------------
#define zf_assert(x) (debug_assert_handler((x), __FILE__, __LINE__)) // 断言 一般用于参数判断 zf_assert(0) 就断言报错
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 Log 信息输出
// 参数说明 x 判断是否触发输出 0-触发输出 1-不触发输出
// 参数说明 *str 需要输出的 Log 信息
// 返回参数 void
// 使用示例 zf_log(0, "Error");
// 备注信息 调试信息输出 用来做一些报错或者警告之类的输出
// 默认情况下会在 Debug UART 输出
// 但如果使用开源库内屏幕接口初始化了屏幕 则会在屏幕上显示
//-------------------------------------------------------------------------------------------------------------------
#define zf_log(x, str) (debug_log_handler((x), (str), __FILE__, __LINE__)) // 调试信息输出 用来做一些报错或者警告之类的输出
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 CPU报错接管
// 返回参数 void
// 备注信息 当触发CPU报错时会通过log信息输出来提醒用户
//-------------------------------------------------------------------------------------------------------------------
#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
{
uint16 type_index;
uint16 display_x_max;
uint16 display_y_max;
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);
}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 *buff, uint32 len);
#endif
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
+559
View File
@@ -0,0 +1,559 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-08-10 Teternal first version
* 2023-12-06 Teternal 更新操作逻辑 修复无数据读取时异常的操作
********************************************************************************************************************/
#include "zf_common_debug.h"
#include "zf_common_fifo.h"
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 FIFO 头指针位移
// 参数说明 *fifo FIFO 对象指针
// 参数说明 offset 偏移量
// 返回参数 void
// 使用示例 fifo_head_offset(fifo, 1);
// 备注信息 本函数在文件内部调用 用户不用关注 也不可修改
//-------------------------------------------------------------------------------------------------------------------
static void fifo_head_offset (fifo_struct *fifo, uint32 offset)
{
fifo->head += offset;
while(fifo->max <= fifo->head) // 如果范围超过则减缓冲区大小 直到小于最大缓冲区大小
{
fifo->head -= fifo->max;
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 FIFO 尾指针位移
// 参数说明 *fifo FIFO 对象指针
// 参数说明 offset 偏移量
// 返回参数 void
// 使用示例 fifo_end_offset(fifo, 1);
// 备注信息 本函数在文件内部调用 用户不用关注 也不可修改
//-------------------------------------------------------------------------------------------------------------------
static void fifo_end_offset (fifo_struct *fifo, uint32 offset)
{
fifo->end += offset;
while(fifo->max <= fifo->end) // 如果范围超过则减缓冲区大小 直到小于最大缓冲区大小
{
fifo->end -= fifo->max;
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 FIFO 重置缓冲器
// 参数说明 *fifo FIFO 对象指针
// 返回参数 void
// 使用示例 fifo_clear(fifo);
// 备注信息 清空当前 FIFO 对象的内存
//-------------------------------------------------------------------------------------------------------------------
fifo_state_enum fifo_clear (fifo_struct *fifo)
{
zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS; // 操作结果初值
do
{
// if(FIFO_IDLE != fifo->execution) // 判断是否当前 FIFO 是否空闲
// {
// return_state = FIFO_RESET_UNDO; // 重置操作未完成
// break;
// }
fifo->execution |= FIFO_RESET; // 重置操作置位
fifo->head = 0; // 重置 FIFO 所有数值复位
fifo->end = 0; // 重置 FIFO 所有数值复位
fifo->size = fifo->max; // 重置 FIFO 所有数值复位
switch(fifo->type)
{
case FIFO_DATA_8BIT: memset(fifo->buffer, 0, fifo->max); break;
case FIFO_DATA_16BIT: memset(fifo->buffer, 0, fifo->max * 2); break;
case FIFO_DATA_32BIT: memset(fifo->buffer, 0, fifo->max * 4); break;
}
fifo->execution = FIFO_IDLE; // 操作状态复位
}while(0);
return return_state;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 FIFO 查询当前数据个数
// 参数说明 *fifo FIFO 对象指针
// 返回参数 uint32 已使用长度
// 使用示例 uint32 len = fifo_used(fifo);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
uint32 fifo_used (fifo_struct *fifo)
{
zf_assert(fifo != NULL);
return (fifo->max - fifo->size); // 返回当前 FIFO 缓冲区中数据个数
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 向 FIFO 中写入数据
// 参数说明 *fifo FIFO 对象指针
// 参数说明 dat 数据
// 返回参数 fifo_state_enum 操作状态
// 使用示例 zf_log(fifo_write_element(&fifo, data) == FIFO_SUCCESS, "fifo_write_byte error");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
fifo_state_enum fifo_write_element (fifo_struct *fifo, uint32 dat)
{
zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS; // 操作结果初值
do
{
if((FIFO_RESET | FIFO_WRITE) & fifo->execution) // 不在写入与重置状态 避免写入竞争与指向错误
{
return_state = FIFO_WRITE_UNDO; // 写入操作未完成
break;
}
fifo->execution |= FIFO_WRITE; // 写入操作置位
if(1 <= fifo->size) // 剩余空间足够装下本次数据
{
switch(fifo->type)
{
case FIFO_DATA_8BIT: ((uint8 *)fifo->buffer)[fifo->head] = (uint8)dat; break;
case FIFO_DATA_16BIT: ((uint16 *)fifo->buffer)[fifo->head] = (uint16)dat; break;
case FIFO_DATA_32BIT: ((uint32 *)fifo->buffer)[fifo->head] = dat; break;
}
fifo_head_offset(fifo, 1); // 头指针偏移
fifo->size -= 1; // 缓冲区剩余长度减小
}
else
{
return_state = FIFO_SPACE_NO_ENOUGH; // 当前 FIFO 缓冲区满 不能再写入数据 返回空间不足
}
fifo->execution &= ~FIFO_WRITE; // 写入操作复位
}while(0);
return return_state;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 向 FIFO 中写入数据
// 参数说明 *fifo FIFO 对象指针
// 参数说明 *dat 数据来源缓冲区指针
// 参数说明 length 需要写入的数据长度
// 返回参数 fifo_state_enum 操作状态
// 使用示例 zf_log(fifo_write_buffer(&fifo, data, 32) == FIFO_SUCCESS, "fifo_write_buffer error");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length)
{
zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS; // 操作结果初值
uint32 temp_length = 0;
do
{
if(NULL == dat)
{
return_state = FIFO_BUFFER_NULL; // 用户缓冲区异常
break;
}
if((FIFO_RESET | FIFO_WRITE) & fifo->execution) // 不在写入与重置状态 避免写入竞争与指向错误
{
return_state = FIFO_WRITE_UNDO; // 写入操作未完成
break;
}
fifo->execution |= FIFO_WRITE; // 写入操作置位
if(length <= fifo->size) // 剩余空间足够装下本次数据
{
temp_length = fifo->max - fifo->head; // 计算头指针距离缓冲区尾还有多少空间
if(length > temp_length) // 距离缓冲区尾长度不足写入数据 环形缓冲区分段操作
{
switch(fifo->type)
{
case FIFO_DATA_8BIT:
{
memcpy(
&(((uint8 *)fifo->buffer)[fifo->head]),
dat, temp_length); // 拷贝第一段数据
fifo_head_offset(fifo, temp_length); // 头指针偏移
memcpy(
&(((uint8 *)fifo->buffer)[fifo->head]),
&(((uint8 *)dat)[temp_length]),
length - temp_length); // 拷贝第二段数据
fifo_head_offset(fifo, length - temp_length); // 头指针偏移
}break;
case FIFO_DATA_16BIT:
{
memcpy(
&(((uint16 *)fifo->buffer)[fifo->head]),
dat, temp_length * 2); // 拷贝第一段数据
fifo_head_offset(fifo, temp_length); // 头指针偏移
memcpy(
&(((uint16 *)fifo->buffer)[fifo->head]),
&(((uint16 *)dat)[temp_length]),
(length - temp_length) * 2); // 拷贝第二段数据
fifo_head_offset(fifo, length - temp_length); // 头指针偏移
}break;
case FIFO_DATA_32BIT:
{
memcpy(
&(((uint32 *)fifo->buffer)[fifo->head]),
dat, temp_length * 4); // 拷贝第一段数据
fifo_head_offset(fifo, temp_length); // 头指针偏移
memcpy(
&(((uint32 *)fifo->buffer)[fifo->head]),
&(((uint32 *)dat)[temp_length]),
(length - temp_length) * 4); // 拷贝第二段数据
fifo_head_offset(fifo, length - temp_length); // 头指针偏移
}break;
}
}
else
{
switch(fifo->type)
{
case FIFO_DATA_8BIT:
{
memcpy(
&(((uint8 *)fifo->buffer)[fifo->head]),
dat, length); // 一次完整写入
fifo_head_offset(fifo, length); // 头指针偏移
}break;
case FIFO_DATA_16BIT:
{
memcpy(
&(((uint16 *)fifo->buffer)[fifo->head]),
dat, length * 2); // 一次完整写入
fifo_head_offset(fifo, length); // 头指针偏移
}break;
case FIFO_DATA_32BIT:
{
memcpy(
&(((uint32 *)fifo->buffer)[fifo->head]),
dat, length * 4); // 一次完整写入
fifo_head_offset(fifo, length); // 头指针偏移
}break;
}
}
fifo->size -= length; // 缓冲区剩余长度减小
}
else
{
return_state = FIFO_SPACE_NO_ENOUGH; // 当前 FIFO 缓冲区满 不能再写入数据 返回空间不足
}
fifo->execution &= ~FIFO_WRITE; // 写入操作复位
}while(0);
return return_state;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 从 FIFO 读取数据
// 参数说明 *fifo FIFO 对象指针
// 参数说明 *dat 目标缓冲区指针
// 参数说明 flag 是否变更 FIFO 状态 可选择是否清空读取的数据
// 返回参数 fifo_state_enum 操作状态
// 使用示例 zf_log(fifo_read_element(&fifo, data, FIFO_READ_ONLY) == FIFO_SUCCESS, "fifo_read_byte error");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
fifo_state_enum fifo_read_element (fifo_struct *fifo, void *dat, fifo_operation_enum flag)
{
zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS; // 操作结果初值
do
{
if(NULL == dat)
{
return_state = FIFO_BUFFER_NULL; // 用户缓冲区异常
}
else
{
if((FIFO_RESET | FIFO_CLEAR) & fifo->execution) // 判断是否当前 FIFO 是否在执行清空或重置操作
{
return_state = FIFO_READ_UNDO; // 读取操作未完成
break;
}
if(1 > fifo_used(fifo))
{
return_state = FIFO_DATA_NO_ENOUGH; // 缓冲区没有数据 返回数据长度不足
break; // 直接退出操作
}
fifo->execution |= FIFO_READ; // 读操作置位
switch(fifo->type)
{
case FIFO_DATA_8BIT: *((uint8 *)dat) = ((uint8 *)fifo->buffer)[fifo->end]; break;
case FIFO_DATA_16BIT: *((uint16 *)dat) = ((uint16 *)fifo->buffer)[fifo->end]; break;
case FIFO_DATA_32BIT: *((uint32 *)dat) = ((uint32 *)fifo->buffer)[fifo->end]; break;
}
fifo->execution &= ~FIFO_READ; // 读操作复位
}
if(FIFO_READ_AND_CLEAN == flag) // 如果选择读取并更改 FIFO 状态
{
if((FIFO_RESET | FIFO_CLEAR | FIFO_READ) == fifo->execution) // 不在 重置 清空 读取 状态 避免异常
{
return_state = FIFO_CLEAR_UNDO; // 清空操作未完成
break;
}
fifo->execution |= FIFO_CLEAR; // 清空作置位
fifo_end_offset(fifo, 1); // 移动 FIFO 头指针
fifo->size += 1; // 释放对应长度空间
fifo->execution &= ~FIFO_CLEAR; // 清空作复位
}
}while(0);
return return_state;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 从 FIFO 读取数据
// 参数说明 *fifo FIFO 对象指针
// 参数说明 *dat 目标缓冲区指针
// 参数说明 *length 读取的数据长度 如果没有这么多数据这里会被修改
// 参数说明 flag 是否变更 FIFO 状态 可选择是否清空读取的数据
// 返回参数 fifo_state_enum 操作状态
// 使用示例 zf_log(fifo_read_buffer(&fifo, data, &length, FIFO_READ_ONLY) == FIFO_SUCCESS, "fifo_read_buffer error");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
fifo_state_enum fifo_read_buffer (fifo_struct *fifo, void *dat, uint32 *length, fifo_operation_enum flag)
{
zf_assert(NULL != fifo);
zf_assert(NULL != length);
fifo_state_enum return_state = FIFO_SUCCESS; // 操作结果初值
uint32 temp_length = 0;
uint32 fifo_data_length = 0;
do
{
if(NULL == dat)
{
return_state = FIFO_BUFFER_NULL;
}
else
{
if((FIFO_RESET | FIFO_CLEAR) & fifo->execution) // 判断是否当前 FIFO 是否在执行清空或重置操作
{
*length = fifo_data_length; // 纠正读取的长度
return_state = FIFO_READ_UNDO; // 读取操作未完成
break;
}
fifo_data_length = fifo_used(fifo); // 获取当前数据有多少
if(*length > fifo_data_length) // 判断长度是否足够
{
*length = fifo_data_length; // 纠正读取的长度
return_state = FIFO_DATA_NO_ENOUGH; // 标志数据不够
if(0 == fifo_data_length) // 如果没有数据 就直接退出
{
fifo->execution &= ~FIFO_READ; // 读操作复位
break;
}
}
fifo->execution |= FIFO_READ; // 读操作置位
temp_length = fifo->max - fifo->end; // 计算尾指针距离缓冲区尾还有多少空间
if(*length <= temp_length) // 足够一次性读取完毕
{
switch(fifo->type)
{
case FIFO_DATA_8BIT: memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), *length); break;
case FIFO_DATA_16BIT: memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->end]), *length * 2); break;
case FIFO_DATA_32BIT: memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->end]), *length * 4); break;
}
}
else
{
switch(fifo->type)
{
case FIFO_DATA_8BIT:
{
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->end]), temp_length);
memcpy(&(((uint8 *)dat)[temp_length]), fifo->buffer, *length - temp_length);
}break;
case FIFO_DATA_16BIT:
{
memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->end]), temp_length * 2);
memcpy(&(((uint16 *)dat)[temp_length]), fifo->buffer, (*length - temp_length) * 2);
}break;
case FIFO_DATA_32BIT:
{
memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->end]), temp_length * 4);
memcpy(&(((uint32 *)dat)[temp_length]), fifo->buffer, (*length - temp_length) * 4);
}break;
}
}
fifo->execution &= ~FIFO_READ; // 读操作复位
}
if(FIFO_READ_AND_CLEAN == flag) // 如果选择读取并更改 FIFO 状态
{
if((FIFO_RESET | FIFO_CLEAR | FIFO_READ) == fifo->execution) // 不在 重置 清空 读取 状态 避免异常
{
return_state = FIFO_CLEAR_UNDO; // 清空操作未完成
break;
}
fifo->execution |= FIFO_CLEAR; // 清空作置位
fifo_end_offset(fifo, *length); // 移动 FIFO 头指针
fifo->size += *length; // 释放对应长度空间
fifo->execution &= ~FIFO_CLEAR; // 清空作复位
}
}while(0);
return return_state;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 从 FIFO 尾部读取指定长度 buffer
// 参数说明 *fifo FIFO 对象指针
// 参数说明 *dat 目标缓冲区指针
// 参数说明 *length 读取的数据长度 如果没有这么多数据这里会被修改
// 参数说明 flag 是否变更 FIFO 状态 可选择是否清空读取的数据
// 返回参数 fifo_state_enum 操作状态
// 使用示例 zf_log(fifo_read_tail_buffer(&fifo, data, &length, FIFO_READ_ONLY) == FIFO_SUCCESS, "fifo_read_buffer error");
// 备注信息 如果使用 FIFO_READ_AND_CLEAN 操作 将会丢弃所有数据并清空整个 FIFO
// 如果使用 FIFO_READ_AND_CLEAN 操作 将会丢弃所有数据并清空整个 FIFO
// 如果使用 FIFO_READ_AND_CLEAN 操作 将会丢弃所有数据并清空整个 FIFO
//-------------------------------------------------------------------------------------------------------------------
fifo_state_enum fifo_read_tail_buffer (fifo_struct *fifo, void *dat, uint32 *length, fifo_operation_enum flag)
{
zf_assert(NULL != fifo);
zf_assert(NULL != length);
fifo_state_enum return_state = FIFO_SUCCESS; // 操作结果初值
uint32 temp_length = 0;
uint32 fifo_data_length = 0;
do
{
if(NULL == dat)
{
return_state = FIFO_BUFFER_NULL;
}
else
{
if((FIFO_RESET | FIFO_CLEAR | FIFO_WRITE) & fifo->execution) // 判断是否当前 FIFO 是否在执行清空或重置操作
{
*length = fifo_data_length; // 纠正读取的长度
return_state = FIFO_READ_UNDO; // 读取操作未完成
break;
}
fifo_data_length = fifo_used(fifo); // 获取当前数据有多少
if(*length > fifo_data_length) // 判断长度是否足够
{
*length = fifo_data_length; // 纠正读取的长度
return_state = FIFO_DATA_NO_ENOUGH; // 标志数据不够
if(0 == fifo_data_length) // 如果没有数据 就直接退出
{
fifo->execution &= ~FIFO_READ; // 读操作复位
break;
}
}
fifo->execution |= FIFO_READ; // 读操作置位
if((fifo->head > fifo->end) || (fifo->head >= *length))
{
switch(fifo->type)
{
case FIFO_DATA_8BIT: memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->head - *length]), *length); break;
case FIFO_DATA_16BIT: memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->head - *length]), *length * 2);break;
case FIFO_DATA_32BIT: memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->head - *length]), *length * 4);break;
}
}
else
{
temp_length = *length - fifo->head; // 计算尾指针距离缓冲区尾还有多少空间
switch(fifo->type)
{
case FIFO_DATA_8BIT:
{
memcpy(dat, &(((uint8 *)fifo->buffer)[fifo->max - temp_length]), temp_length);
memcpy(&(((uint8 *)dat)[temp_length]), &(((uint8 *)fifo->buffer)[fifo->head - *length]), (*length - temp_length));
}break;
case FIFO_DATA_16BIT:
{
memcpy(dat, &(((uint16 *)fifo->buffer)[fifo->max - temp_length]), temp_length * 2);
memcpy(&(((uint16 *)dat)[temp_length]), &(((uint16 *)fifo->buffer)[fifo->head - *length]), (*length - temp_length) * 2);
}break;
case FIFO_DATA_32BIT:
{
memcpy(dat, &(((uint32 *)fifo->buffer)[fifo->max - temp_length]), temp_length * 4);
memcpy(&(((uint32 *)dat)[temp_length]), &(((uint32 *)fifo->buffer)[fifo->head - *length]), (*length - temp_length) * 4);
}break;
}
}
fifo->execution &= ~FIFO_READ; // 读操作复位
}
if(FIFO_READ_AND_CLEAN == flag) // 如果选择读取并更改 FIFO 状态
{
if((FIFO_RESET | FIFO_CLEAR | FIFO_READ) == fifo->execution) // 不在 重置 清空 读取 状态 避免异常
{
return_state = FIFO_CLEAR_UNDO; // 清空操作未完成
break;
}
fifo_clear(fifo);
}
}while(0);
return return_state;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 FIFO 初始化 挂载对应缓冲区
// 参数说明 *fifo FIFO 对象指针
// 参数说明 type FIFO 数据位数
// 参数说明 *buffer_addr 要挂载的缓冲区
// 参数说明 size 缓冲区大小
// 返回参数 fifo_state_enum 操作状态
// 使用示例 fifo_init(&user_fifo, user_buffer, 64);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
fifo_state_enum fifo_init (fifo_struct *fifo, fifo_data_type_enum type, void *buffer_addr, uint32 size)
{
zf_assert(NULL != fifo);
fifo_state_enum return_state = FIFO_SUCCESS;
do
{
fifo->buffer = buffer_addr;
fifo->execution = FIFO_IDLE;
fifo->type = type;
fifo->head = 0;
fifo->end = 0;
fifo->size = size;
fifo->max = size;
}while(0);
return return_state;
}
+107
View File
@@ -0,0 +1,107 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_fifo
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-08-10 Teternal first version
* 2023-12-06 Teternal 更新操作逻辑 修复无数据读取时异常的操作
********************************************************************************************************************/
#ifndef _zf_common_fifo_h_
#define _zf_common_fifo_h_
#include "zf_common_typedef.h"
typedef enum
{
FIFO_SUCCESS, // FIFO 操作成功
FIFO_RESET_UNDO, // FIFO 重置操作未执行
FIFO_CLEAR_UNDO, // FIFO 清空操作未执行
FIFO_BUFFER_NULL, // FIFO 用户缓冲区异常
FIFO_WRITE_UNDO, // FIFO 写入操作未执行
FIFO_SPACE_NO_ENOUGH, // FIFO 写入操作 缓冲区空间不足
FIFO_READ_UNDO, // FIFO 读取操作未执行
FIFO_DATA_NO_ENOUGH, // FIFO 读取操作 数据长度不足
}fifo_state_enum; // FIFO 操作结果
// 操作逻辑
// 整体重置操作 将会强制清空 FIFO 谨慎使用
// 数据写入操作 不能在重置以及写入操作时进行
// 顺序读取操作 不能在清空和重置操作时进行
// 尾部读取操作 不能在清空和重置以及写入操作时进行
// 读取清空操作 不能在清空和重置以及读取操作时进行
// 这是为了防止中断嵌套导致数据混乱
typedef enum
{
FIFO_IDLE = 0x00, // 空闲状态
FIFO_RESET = 0x01, // 正在执行重置缓冲区
FIFO_CLEAR = 0x02, // 正在执行清空缓冲区
FIFO_WRITE = 0x04, // 正在执行写入缓冲区
FIFO_READ = 0x08, // 正在执行读取缓冲区
}fifo_execution_enum; // FIFO 操作状态 为嵌套使用预留 无法完全避免误操作
typedef enum
{
FIFO_READ_AND_CLEAN, // FIFO 读操作模式 读取后清空释放对应缓冲区
FIFO_READ_ONLY, // FIFO 读操作模式 仅读取
}fifo_operation_enum;
typedef enum
{
FIFO_DATA_8BIT, // FIFO 数据位宽 8bit
FIFO_DATA_16BIT, // FIFO 数据位宽 16bit
FIFO_DATA_32BIT, // FIFO 数据位宽 32bit
}fifo_data_type_enum;
typedef struct
{
uint8 execution; // 执行步骤
fifo_data_type_enum type; // 数据类型
void *buffer; // 缓存指针
uint32 head; // 缓存头指针 总是指向空的缓存
uint32 end; // 缓存尾指针 总是指向非空缓存(缓存全空除外)
uint32 size; // 缓存剩余大小
uint32 max; // 缓存总大小
}fifo_struct;
fifo_state_enum fifo_clear (fifo_struct *fifo);
uint32 fifo_used (fifo_struct *fifo);
fifo_state_enum fifo_write_element (fifo_struct *fifo, uint32 dat);
fifo_state_enum fifo_write_buffer (fifo_struct *fifo, void *dat, uint32 length);
fifo_state_enum fifo_read_element (fifo_struct *fifo, void *dat, fifo_operation_enum flag);
fifo_state_enum fifo_read_buffer (fifo_struct *fifo, void *dat, uint32 *length, fifo_operation_enum flag);
fifo_state_enum fifo_read_tail_buffer (fifo_struct *fifo, void *dat, uint32 *length, fifo_operation_enum flag);
fifo_state_enum fifo_init (fifo_struct *fifo, fifo_data_type_enum type, void *buffer_addr, uint32 size);
#endif
File diff suppressed because it is too large. Load diff
+68
View File
@@ -0,0 +1,68 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_font
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
********************************************************************************************************************/
#ifndef _zf_common_font_h
#define _zf_common_font_h
#include "zf_common_typedef.h"
//-------常用颜色----------
typedef enum
{
RGB565_WHITE = (0xFFFF), // 白色
RGB565_BLACK = (0x0000), // 黑色
RGB565_BLUE = (0x001F), // 蓝色
RGB565_PURPLE = (0xF81F), // 紫色
RGB565_PINK = (0xFE19), // 粉色
RGB565_RED = (0xF800), // 红色
RGB565_MAGENTA = (0xF81F), // 品红
RGB565_GREEN = (0x07E0), // 绿色
RGB565_CYAN = (0x07FF), // 青色
RGB565_YELLOW = (0xFFE0), // 黄色
RGB565_BROWN = (0xBC40), // 棕色
RGB565_GRAY = (0x8430), // 灰色
RGB565_39C5BB = (0x3616),
RGB565_66CCFF = (0x665F),
}rgb565_color_enum;
extern const uint8 ascii_font_8x16[][16];
extern const uint8 ascii_font_6x8[][6];
extern const uint8 chinese_test[8][16];
extern const uint8 oled_16x16_chinese[][16];
extern const uint8 gImage_seekfree_logo[38400];
#endif
+905
View File
@@ -0,0 +1,905 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
********************************************************************************************************************/
#include "zf_common_debug.h"
#include "zf_common_function.h"
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 获取整型数的最大公约数 九章算术之更相减损术
// 参数说明 num1 数字1
// 参数说明 num2 数字2
// 返回参数 uint32 最大公约数
// 使用示例 return func_get_greatest_common_divisor(144, 36); // 获取 144 与 36 的最大公约数
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
uint32 func_get_greatest_common_divisor (uint32 num1, uint32 num2)
{
while(num1 != num2)
{
if(num1 > num2)
{
num1 = num1 - num2;
}
if(num1 < num2)
{
num2 = num2 - num1;
}
}
return num1;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 软件延时
// 参数说明 t 延时时间
// 返回参数 void
// 使用示例 func_soft_delay(100);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void func_soft_delay (volatile long t)
{
while(t --);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 字符串转整形数字 数据范围是 [-32768,32767]
// 参数说明 *str 传入字符串 可带符号
// 返回参数 int32 转换后的数据
// 使用示例 int32 dat = func_str_to_int("-100");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
int32 func_str_to_int (char *str)
{
zf_assert(str != NULL);
uint8 sign = 0; // 标记符号 0-正数 1-负数
int32 temp = 0; // 临时计算变量
do
{
if(NULL == str)
{
break;
}
if('-' == *str) // 如果第一个字符是负号
{
sign = 1; // 标记负数
str ++;
}
else if('+' == *str) // 如果第一个字符是正号
{
str ++;
}
while(('0' <= *str) && ('9' >= *str)) // 确定这是个数字
{
temp = temp * 10 + ((uint8)(*str) - 0x30); // 计算数值
str ++;
}
if(sign)
{
temp = -temp;
}
}while(0);
return temp;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 整形数字转字符串 数据范围是 [-32768,32767]
// 参数说明 *str 字符串指针
// 参数说明 number 传入的数据
// 返回参数 void
// 使用示例 func_int_to_str(data_buffer, -300);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void func_int_to_str (char *str, int32 number)
{
zf_assert(str != NULL);
uint8 data_temp[16]; // 缓冲区
uint8 bit = 0; // 数字位数
int32 number_temp = 0;
do
{
if(NULL == str)
{
break;
}
if(0 > number) // 负数
{
*str ++ = '-';
number = -number;
}
else if(0 == number) // 或者这是个 0
{
*str = '0';
break;
}
while(0 != number) // 循环直到数值归零
{
number_temp = number % 10;
data_temp[bit ++] = func_abs(number_temp); // 倒序将数值提取出来
number /= 10; // 削减被提取的个位数
}
while(0 != bit) // 提取的数字个数递减处理
{
*str ++ = (data_temp[bit - 1] + 0x30); // 将数字从倒序数组中倒序取出 变成正序放入字符串
bit --;
}
}while(0);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 字符串转整形数字 数据范围是 [0,65535]
// 参数说明 *str 传入字符串 无符号
// 返回参数 uint32 转换后的数据
// 使用示例 uint32 dat = func_str_to_uint("100");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
uint32 func_str_to_uint (char *str)
{
zf_assert(str != NULL);
uint32 temp = 0; // 临时计算变量
do
{
if(NULL == str)
{
break;
}
while(('0' <= *str) && ('9' >= *str)) // 确定这是个数字
{
temp = temp * 10 + ((uint8)(*str) - 0x30); // 计算数值
str ++;
}
}while(0);
return temp;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 整形数字转字符串 数据范围是 [0,65535]
// 参数说明 *str 字符串指针
// 参数说明 number 传入的数据
// 返回参数 void
// 使用示例 func_uint_to_str(data_buffer, 300);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void func_uint_to_str (char *str, uint32 number)
{
zf_assert(str != NULL);
int8 data_temp[16]; // 缓冲区
uint8 bit = 0; // 数字位数
do
{
if(NULL == str)
{
break;
}
if(0 == number) // 这是个 0
{
*str = '0';
break;
}
while(0 != number) // 循环直到数值归零
{
data_temp[bit ++] = (number % 10); // 倒序将数值提取出来
number /= 10; // 削减被提取的个位数
}
while(0 != bit) // 提取的数字个数递减处理
{
*str ++ = (data_temp[bit - 1] + 0x30); // 将数字从倒序数组中倒序取出 变成正序放入字符串
bit --;
}
}while(0);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 字符串转浮点数 有效累计精度为小数点后六位
// 参数说明 *str 传入字符串 可带符号
// 返回参数 float 转换后的数据
// 使用示例 float dat = func_str_to_float("-100.2");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
float func_str_to_float (char *str)
{
zf_assert(str != NULL);
uint8 sign = 0; // 标记符号 0-正数 1-负数
float temp = 0.0; // 临时计算变量 整数部分
float temp_point = 0.0; // 临时计算变量 小数部分
float point_bit = 1; // 小数累计除数
do
{
if(NULL == str)
{
break;
}
if('-' == *str) // 负数
{
sign = 1; // 标记负数
str ++;
}
else if('+' == *str) // 如果第一个字符是正号
{
str ++;
}
// 提取整数部分
while(('0' <= *str) && ('9' >= *str)) // 确定这是个数字
{
temp = temp * 10 + ((uint8)(*str) - 0x30); // 将数值提取出来
str ++;
}
if('.' == *str)
{
str ++;
while(('0' <= *str) && ('9' >= *str) && point_bit < 1000000.0) // 确认这是个数字 并且精度控制还没到六位
{
temp_point = temp_point * 10 + ((uint8)(*str) - 0x30); // 提取小数部分数值
point_bit *= 10; // 计算这部分小数的除数
str ++;
}
temp_point /= point_bit; // 计算小数
}
temp += temp_point; // 将数值拼合
if(sign)
{
temp = -temp;
}
}while(0);
return temp;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 浮点数字转字符串
// 参数说明 *str 字符串指针
// 参数说明 number 传入的数据
// 参数说明 point_bit 小数点精度
// 返回参数 void
// 使用示例 func_float_to_str(data_buffer, 3.1415, 2); // 结果输出 data_buffer = "3.14"
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void func_float_to_str (char *str, float number, uint8 point_bit)
{
zf_assert(str != NULL);
int data_int = 0; // 整数部分
int data_float = 0.0; // 小数部分
int data_temp[8]; // 整数字符缓冲
int data_temp_point[6]; // 小数字符缓冲
uint8 bit = point_bit; // 转换精度位数
do
{
if(NULL == str)
{
break;
}
// 提取整数部分
data_int = (int)number; // 直接强制转换为 int
if(0 > number) // 判断源数据是正数还是负数
{
*str ++ = '-';
}
else if(0.0 == number) // 如果是个 0
{
*str ++ = '0';
*str ++ = '.';
*str = '0';
break;
}
// 提取小数部分
number = number - data_int; // 减去整数部分即可
while(bit --)
{
number = number * 10; // 将需要的小数位数提取到整数部分
}
data_float = (int)number; // 获取这部分数值
// 整数部分转为字符串
bit = 0;
do
{
data_temp[bit ++] = data_int % 10; // 将整数部分倒序写入字符缓冲区
data_int /= 10;
}while(0 != data_int);
while(0 != bit)
{
*str ++ = (func_abs(data_temp[bit - 1]) + 0x30); // 再倒序将倒序的数值写入字符串 得到正序数值
bit --;
}
// 小数部分转为字符串
if(point_bit != 0)
{
bit = 0;
*str ++ = '.';
if(0 == data_float)
{
*str = '0';
}
else
{
while(0 != point_bit) // 判断有效位数
{
data_temp_point[bit ++] = data_float % 10; // 倒序写入字符缓冲区
data_float /= 10;
point_bit --;
}
while(0 != bit)
{
*str ++ = (func_abs(data_temp_point[bit - 1]) + 0x30); // 再倒序将倒序的数值写入字符串 得到正序数值
bit --;
}
}
}
}while(0);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 字符串转浮点数 有效累计精度为小数点后九位
// 参数说明 str 传入字符串 可带符号
// 返回参数 double 转换后的数据
// 使用示例 double dat = func_str_to_double("-100.2");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
double func_str_to_double (char *str)
{
zf_assert(str != NULL);
uint8 sign = 0; // 标记符号 0-正数 1-负数
double temp = 0.0; // 临时计算变量 整数部分
double temp_point = 0.0; // 临时计算变量 小数部分
double point_bit = 1; // 小数累计除数
do
{
if(NULL == str)
{
break;
}
if('-' == *str) // 负数
{
sign = 1; // 标记负数
str ++;
}
else if('+' == *str) // 如果第一个字符是正号
{
str ++;
}
// 提取整数部分
while(('0' <= *str) && ('9' >= *str)) // 确定这是个数字
{
temp = temp * 10 + ((uint8)(*str) - 0x30); // 将数值提取出来
str ++;
}
if('.' == *str)
{
str ++;
while(('0' <= *str) && ('9' >= *str) && point_bit < 1000000000.0) // 确认这是个数字 并且精度控制还没到九位
{
temp_point = temp_point * 10 + ((uint8)(*str) - 0x30); // 提取小数部分数值
point_bit *= 10; // 计算这部分小数的除数
str ++;
}
temp_point /= point_bit; // 计算小数
}
temp += temp_point; // 将数值拼合
if(sign)
{
temp = -temp;
}
}while(0);
return temp;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 浮点数字转字符串
// 参数说明 *str 字符串指针
// 参数说明 number 传入的数据
// 参数说明 point_bit 小数点精度
// 返回参数 void
// 使用示例 func_double_to_str(data_buffer, 3.1415, 2); // 结果输出 data_buffer = "3.14"
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void func_double_to_str (char *str, double number, uint8 point_bit)
{
zf_assert(str != NULL);
int data_int = 0; // 整数部分
int data_float = 0.0; // 小数部分
int data_temp[12]; // 整数字符缓冲
int data_temp_point[9]; // 小数字符缓冲
uint8 bit = point_bit; // 转换精度位数
do
{
if(NULL == str)
{
break;
}
// 提取整数部分
data_int = (int)number; // 直接强制转换为 int
if(0 > number) // 判断源数据是正数还是负数
{
*str ++ = '-';
}
else if(0.0 == number) // 如果是个 0
{
*str ++ = '0';
*str ++ = '.';
*str = '0';
break;
}
// 提取小数部分
number = number - data_int; // 减去整数部分即可
while(bit --)
{
number = number * 10; // 将需要的小数位数提取到整数部分
}
data_float = (int)number; // 获取这部分数值
// 整数部分转为字符串
bit = 0;
do
{
data_temp[bit ++] = data_int % 10; // 将整数部分倒序写入字符缓冲区
data_int /= 10;
}while(0 != data_int);
while(0 != bit)
{
*str ++ = (func_abs(data_temp[bit - 1]) + 0x30); // 再倒序将倒序的数值写入字符串 得到正序数值
bit --;
}
// 小数部分转为字符串
if(point_bit != 0)
{
bit = 0;
*str ++ = '.';
if(0 == data_float)
*str = '0';
else
{
while(0 != point_bit) // 判断有效位数
{
data_temp_point[bit ++] = data_float % 10; // 倒序写入字符缓冲区
data_float /= 10;
point_bit --;
}
while(0 != bit)
{
*str ++ = (func_abs(data_temp_point[bit - 1]) + 0x30); // 再倒序将倒序的数值写入字符串 得到正序数值
bit --;
}
}
}
}while(0);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 字符串转 Hex
// 参数说明 str 传入字符串 无符号
// 返回参数 uint32 转换后的数据
// 使用示例 uint32 dat = func_str_to_hex("0x11");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
uint32 func_str_to_hex (char *str)
{
zf_assert(str != NULL);
uint32 str_len = strlen(str); // 字符串长
uint32 result_data = 0; // 结果缓存
uint8 temp = 0; // 计算变量
uint8 flag = 0; // 标志位
do
{
if(NULL == str)
{
break;
}
if(flag)
{
if(('a' <= *str) && ('f' >= *str))
{
temp = (*str - 87);
}
else if(('A' <= *str) && ('F' >= *str))
{
temp = (*str - 55);
}
else if(('0' <= *str) && ('9' >= *str))
{
temp = (*str - 48);
}
else
{
break;
}
result_data = ((result_data << 4) | (temp & 0x0F));
}
else
{
// if(strncmp("0x", str, 2))
if((*str == '0') && (*(str + 1) == 'x'))
{
str ++;
flag = 1;
}
}
str ++;
}while(str_len --);
return result_data;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 Hex 转字符串
// 参数说明 *str 字符串指针
// 参数说明 number 传入的数据
// 返回参数 void
// 使用示例 func_hex_to_str(data_buffer, 0x11); // 结果输出 data_buffer = "0x11"
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void func_hex_to_str (char *str, uint32 number)
{
zf_assert(str != NULL);
const char hex_index[16] = {
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'A', 'B',
'C', 'D', 'E', 'F'};
int8 data_temp[12]; // 缓冲区
uint8 bit = 0; // 数字位数
*str++ = '0';
*str++ = 'x';
do
{
if(NULL == str)
{
break;
}
if(0 == number) // 这是个 0
{
*str = '0';
break;
}
while(0 != number) // 循环直到数值归零
{
data_temp[bit ++] = (number & 0xF); // 倒序将数值提取出来
number >>= 4; // 削减被提取的个位数
}
while(0 != bit) // 提取的数字个数递减处理
{
*str ++ = hex_index[data_temp[bit - 1]]; // 将数字从倒序数组中倒序取出 变成正序放入字符串
bit --;
}
}while(0);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 数字转换为 ASCII 值
// 参数说明 dat 传入的数据
// 参数说明 *p 数据缓冲
// 参数说明 neg_type 数据类型
// 参数说明 radix 进制
// 返回参数 uint8 数据
// 使用示例 number_conversion_ascii((uint32)ival, vstr, 1, 10);
// 备注信息 本函数在文件内部调用 用户不用关注 也不可修改
//-------------------------------------------------------------------------------------------------------------------
static uint8 number_conversion_ascii (uint32 dat, int8 *p, uint8 neg_type, uint8 radix)
{
int32 neg_dat;
uint32 pos_dat;
uint8 temp_data = 0;
uint8 valid_num = 0;
if(neg_type)
{
neg_dat = (int32)dat;
if(0 > neg_dat)
{
neg_dat = -neg_dat;
}
while(1)
{
*p = neg_dat%radix + '0';
neg_dat = neg_dat/radix;
valid_num ++;
if(!neg_dat)
{
break;
}
p ++;
}
}
else
{
pos_dat = dat;
while(1)
{
temp_data = pos_dat%radix;
if(10 <= temp_data)
{
temp_data += 'A'-10;
}
else
{
temp_data += '0';
}
*p = temp_data;
pos_dat = pos_dat/radix;
valid_num ++;
if(!pos_dat)
{
break;
}
p ++;
}
}
return valid_num;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 printf 显示转换
// 参数说明 *d_buff 缓冲区
// 参数说明 len 长度
// 返回参数 void
// 使用示例 printf_reverse_order(vstr, vlen);
// 备注信息 本函数在文件内部调用 用户不用关注 也不可修改
//-------------------------------------------------------------------------------------------------------------------
static void printf_reverse_order (int8 *d_buff, uint32 len)
{
uint32 i;
int8 temp_data;
for(i = 0; len / 2 > i; i ++)
{
temp_data = d_buff[len - 1 - i];
d_buff[len - 1 -i ] = d_buff[i];
d_buff[i] = temp_data;
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 sprintf 函数实现
// 参数说明 *buff 缓冲区
// 参数说明 *format 源字符串
// 参数说明 ... 可变参数列表
// 返回参数 uint32 处理后数据长
// 使用示例 zf_sprintf(buff, "Data : %d", 100);
// 备注信息 本函数在文件内部调用 用户不用关注 也不可修改
//-------------------------------------------------------------------------------------------------------------------
uint32 zf_sprintf (int8 *buff, const int8 *format, ...)
{
uint32 buff_len = 0;
va_list arg;
va_start(arg, format);
while (*format)
{
int8 ret = *format;
if ('%' == ret)
{
switch (*++ format)
{
case 'a':// 十六进制p计数法输出浮点数 暂未实现
{
}
break;
case 'c':// 一个字符
{
int8 ch = (int8)va_arg(arg, uint32);
*buff = ch;
buff ++;
buff_len ++;
}
break;
case 'd':
case 'i':// 有符号十进制整数
{
int8 vstr[33];
int32 ival = (int32)va_arg(arg, int32);
uint8 vlen = number_conversion_ascii((uint32)ival, vstr, 1, 10);
if(0 > ival)
{
vstr[vlen] = '-';
vlen ++;
}
printf_reverse_order(vstr, vlen);
memcpy(buff, vstr, vlen);
buff += vlen;
buff_len += vlen;
}
break;
case 'f':// 浮点数,输出小数点后六位 不能指定输出精度
case 'F':// 浮点数,输出小数点后六位 不能指定输出精度
{
int8 vstr[33];
double ival = (double)va_arg(arg, double);
uint8 vlen = number_conversion_ascii((uint32)(int32)ival, vstr, 1, 10);
if(0 > ival)
{
vstr[vlen] = '-';
vlen ++;
}
printf_reverse_order(vstr, vlen);
memcpy(buff, vstr, vlen);
buff += vlen;
buff_len += vlen;
ival = ((double)ival - (int32)ival)*1000000;
if(ival)
{
vlen = number_conversion_ascii((uint32)(int32)ival, vstr, 1, 10);
}
else
{
vstr[0] = vstr[1] = vstr[2] = vstr[3] = vstr[4] = vstr[5] = '0';
vlen = 6;
}
while(6 > vlen)
{
vstr[vlen] = '0';
vlen ++;
}
vstr[vlen] = '.';
vlen ++;
printf_reverse_order(vstr, vlen);
memcpy(buff, vstr, vlen);
buff_len += vlen;
}
break;
case 'u':// 无符号十进制整数
{
int8 vstr[33];
uint32 ival = (uint32)va_arg(arg, uint32);
uint8 vlen = number_conversion_ascii(ival, vstr, 0, 10);
printf_reverse_order(vstr, vlen);
memcpy(buff, vstr, vlen);
buff += vlen;
buff_len += vlen;
}
break;
case 'o':// 无符号八进制整数
{
int8 vstr[33];
uint32 ival = (uint32)va_arg(arg, uint32);
uint8 vlen = number_conversion_ascii(ival, vstr, 0, 8);
printf_reverse_order(vstr, vlen);
memcpy(buff, vstr, vlen);
buff += vlen;
buff_len += vlen;
}
break;
case 'x':// 无符号十六进制整数
case 'X':// 无符号十六进制整数
{
int8 vstr[33];
uint32 ival = (uint32)va_arg(arg, uint32);
uint8 vlen = number_conversion_ascii(ival, vstr, 0, 16);
printf_reverse_order(vstr, vlen);
memcpy(buff, vstr, vlen);
buff += vlen;
buff_len += vlen;
}
break;
case 's':// 字符串
{
int8 *pc = va_arg(arg, int8 *);
while (*pc)
{
*buff = *pc;
buff ++;
buff_len ++;
pc ++;
}
}
break;
case 'p':// 以16进制形式输出指针
{
int8 vstr[33];
uint32 ival = (uint32)va_arg(arg, uint32);
uint8 vlen = 0;
vlen = number_conversion_ascii(ival, vstr, 0, 16);
printf_reverse_order(vstr, 8);
memcpy(buff, vstr, 8);
buff += 8;
buff_len += 8;
}
break;
case '%':// 输出字符%
{
*buff = '%';
buff ++;
buff_len ++;
}
break;
default:
break;
}
}
else
{
*buff = (int8)(*format);
buff ++;
buff_len ++;
}
format ++;
}
va_end(arg);
return buff_len;
}
+97
View File
@@ -0,0 +1,97 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_function
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
********************************************************************************************************************/
#ifndef _zf_common_function_h_
#define _zf_common_function_h_
#include "zf_common_typedef.h"
//====================================================宏定义函数区====================================================
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 绝对值函数 数据范围是 [-32767,32767]
// 参数说明 dat 需要求绝对值的数
// 返回参数 int 返回绝对值
// 使用示例 dat = func_abs(dat); // 将dat变成正数
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
#define func_abs(x) ((x) >= 0 ? (x): -(x))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 限幅 数据范围是 [-32768,32767]
// 参数说明 x 被限幅的数据
// 参数说明 y 限幅范围(数据会被限制在-y至+y之间)
// 返回参数 int 限幅之后的数据
// 使用示例 int dat = func_limit(500, 300); // 数据被限制在-300至+300之间 因此返回的结果是300
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
#define func_limit(x, y) ((x) > (y) ? (y) : ((x) < -(y) ? -(y) : (x)))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 双边限幅 数据范围是 [-32768,32767]
// 参数说明 x 被限幅的数据
// 参数说明 a 限幅范围左边界
// 参数说明 b 限幅范围右边界
// 返回参数 int 限幅之后的数据
// 使用示例 int dat = func_limit_ab(500, -300, 400); //数据被限制在-300至+400之间 因此返回的结果是400
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
#define func_limit_ab(x, a, b) ((x) < (a) ? (a) : ((x) > (b) ? (b) : (x)))
//====================================================宏定义函数区====================================================
//=====================================================常规函数区=====================================================
uint32 func_get_greatest_common_divisor (uint32 num1, uint32 num2);
void func_soft_delay (volatile long t);
int32 func_str_to_int (char *str);
void func_int_to_str (char *str, int32 number);
uint32 func_str_to_uint (char *str);
void func_uint_to_str (char *str, uint32 number);
float func_str_to_float (char *str);
void func_float_to_str (char *str, float number, uint8 point_bit);
double func_str_to_double (char *str);
void func_double_to_str (char *str, double number, uint8 point_bit);
uint32 func_str_to_hex (char *str);
void func_hex_to_str (char *str, uint32 number);
uint32 zf_sprintf (int8 *buff, const int8 *format, ...);
//=====================================================常规函数区=====================================================
#endif
+126
View File
@@ -0,0 +1,126 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_headfile
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
********************************************************************************************************************/
#ifndef _zf_common_headfile_h_
#define _zf_common_headfile_h_
//===================================================C语言 函数库===================================================
#include "math.h"
#include "stdio.h"
#include "stdint.h"
#include "stdbool.h"
#include "string.h"
//===================================================C语言 函数库===================================================
//===================================================芯片 SDK 底层===================================================
#include "ifxAsclin_reg.h"
#include "SysSe/Bsp/Bsp.h"
#include "IfxCcu6_Timer.h"
#include "IfxScuEru.h"
//===================================================芯片 SDK 底层===================================================
//====================================================开源库公共层====================================================
#include "zf_common_typedef.h"
#include "zf_common_clock.h"
#include "zf_common_debug.h"
#include "zf_common_fifo.h"
#include "zf_common_font.h"
#include "zf_common_function.h"
#include "zf_common_interrupt.h"
#include "isr_config.h"
//====================================================开源库公共层====================================================
//===================================================芯片外设驱动层===================================================
#include "zf_driver_adc.h"
#include "zf_driver_delay.h"
#include "zf_driver_dma.h"
#include "zf_driver_encoder.h"
#include "zf_driver_exti.h"
#include "zf_driver_flash.h"
#include "zf_driver_gpio.h"
#include "zf_driver_pit.h"
#include "zf_driver_pwm.h"
#include "zf_driver_soft_iic.h"
#include "zf_driver_spi.h"
#include "zf_driver_soft_spi.h"
#include "zf_driver_uart.h"
#include "zf_driver_timer.h"
//===================================================芯片外设驱动层===================================================
//===================================================外接设备驱动层===================================================
#include "zf_device_absolute_encoder.h"
#include "zf_device_ble6a20.h"
#include "zf_device_bluetooth_ch9141.h"
#include "zf_device_gnss.h"
#include "zf_device_camera.h"
#include "zf_device_dl1a.h"
#include "zf_device_dl1b.h"
#include "zf_device_icm20602.h"
#include "zf_device_imu660ra.h"
#include "zf_device_imu660rb.h"
#include "zf_device_imu660rc.h"
#include "zf_device_imu660rx.h"
#include "zf_device_imu963ra.h"
#include "zf_device_ips114.h"
#include "zf_device_ips200.h"
#include "zf_device_ips200pro.h"
#include "zf_device_key.h"
#include "zf_device_menc15a.h"
#include "zf_device_mpu6050.h"
#include "zf_device_mt9v03x_double.h"
#include "zf_device_oled.h"
#include "zf_device_ov7725.h"
#include "zf_device_scc8660.h"
#include "zf_device_tft180.h"
#include "zf_device_tsl1401.h"
#include "zf_device_type.h"
#include "zf_device_uart_receiver.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"
//===================================================外接设备驱动层===================================================
//====================================================应用组件层====================================================
#include "seekfree_assistant.h"
#include "seekfree_assistant_interface.h"
//====================================================应用组件层====================================================
//=====================================================用户层======================================================
//=====================================================用户层======================================================
#endif
+84
View File
@@ -0,0 +1,84 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
********************************************************************************************************************/
#include "SysSe/Bsp/Bsp.h"
#include "zf_common_interrupt.h"
#include "zf_driver_pit.h"
#include "zf_driver_pwm.h"
#include "zf_driver_exti.h"
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 全局中断使能
// 参数说明 void
// 返回参数 void
// 使用示例 interrupt_global_enable(0);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void interrupt_global_enable (uint32 primask)
{
if(primask == 0)
{
enableInterrupts();
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 全局中断屏蔽
// 参数说明 void
// 返回参数 void
// 使用示例 uint32 interrupt_num = interrupt_global_disable();
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
uint32 interrupt_global_disable (void)
{
return (uint32)(!disableInterrupts());
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 断言中断配置
// 参数说明 void
// 返回参数 void
// 使用示例 assert_interrupt_config();
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
void assert_interrupt_config (void)
{
interrupt_global_disable(); // 全局中断失能
pit_all_close(); // 关闭所有pit中断
pwm_all_channel_close(); // 关闭PWM所有通道输出
exti_all_close(); // 关闭所有外部触发中断
interrupt_global_enable(0); // 全局中断使能
}
+46
View File
@@ -0,0 +1,46 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_interrupt
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
********************************************************************************************************************/
#ifndef _zf_common_interrupt_h_
#define _zf_common_interrupt_h_
#include "zf_common_typedef.h"
void interrupt_global_enable (uint32 primask); // 全局中断使能
uint32 interrupt_global_disable (void); // 全局中断失能
void assert_interrupt_config (void); // 断言中断配置
#endif
+79
View File
@@ -0,0 +1,79 @@
/*********************************************************************************************************************
* TC264 Opensourec Library 即(TC264 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是 TC264 开源库的一部分
*
* TC264 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
* 更多细节请参见 GPL
*
* 您应该在收到本开源库的同时收到一份 GPL 的副本
* 如果没有,请参阅<https://www.gnu.org/licenses/>
*
* 额外注明:
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
*
* 文件名称 zf_common_typedef
* 公司名称 成都逐飞科技有限公司
* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
* 开发环境 ADS v1.10.2
* 适用平台 TC264D
* 店铺链接 https://seekfree.taobao.com/
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 pudding first version
********************************************************************************************************************/
#ifndef _zf_common_typedef_h_
#define _zf_common_typedef_h_
#include "math.h"
#include "stdio.h"
#include "stdint.h"
#include "stdarg.h"
#include "string.h"
#include "stdlib.h"
#include "ifx_types.h"
#include "PLATFORM_TYPES.H"
//=================================================== 类型定义 ===================================================
//#define COMPATIBLE_WITH_OLDER_VERSIONS // 兼容旧版开源库接口
#define USE_ZF_TYPEDEF (1) // 是否启用类型定义申明
#if USE_ZF_TYPEDEF
// 数据类型声明
// 尽量使用 stdint.h 定义的类型名称 避免冲突 这里可以裁剪
typedef signed char int8; // 有符号 8 bits
typedef signed short int int16; // 有符号 16 bits
typedef signed int int32; // 有符号 32 bits
typedef signed long long int64; // 有符号 64 bits
typedef volatile uint8 vuint8; // 易变性修饰 无符号 8 bits
typedef volatile uint16 vuint16; // 易变性修饰 无符号 16 bits
typedef volatile uint32 vuint32; // 易变性修饰 无符号 32 bits
typedef volatile uint64 vuint64; // 易变性修饰 无符号 64 bits
typedef volatile int8 vint8; // 易变性修饰 有符号 8 bits
typedef volatile int16 vint16; // 易变性修饰 有符号 16 bits
typedef volatile int32 vint32; // 易变性修饰 有符号 32 bits
typedef volatile int64 vint64; // 易变性修饰 有符号 64 bits
#endif
#define ZF_ENABLE (1)
#define ZF_DISABLE (0)
#define ZF_TRUE (1)
#define ZF_FALSE (0)
#define ZF_WEAK __attribute__((weak))
//=================================================== 类型定义 ===================================================
#endif