ST17H66串口文件.zip
大小:2.6KB
价格:10积分
下载量:0
评分:
5.0
上传者:qq_39724355
更新日期:2025-09-22

ST17H66串口文件.zip

资源文件列表(大概)

文件名
大小
my_printf.c
9.47KB

资源内容介绍

ST17H66转发收到的串口信息
#include "rom_sym_def.h"#include "types.h"#include <stdarg.h>#include <string.h>#include "uart.h"#include "log.h"#define ZEROPAD 1 // Pad with zero#define SIGN 2 // Unsigned/signed long#define PLUS 4 // Show plus#define SPACE 8 // Space if plus#define LEFT 16 // Left justified#define SPECIAL 32 // 0x#define LARGE 64 // Use 'ABCDEF' instead of 'abcdef'#define is_digit(c) ((c) >= '0' && (c) <= '9')static const char* digits = "0123456789abcdefghijklmnopqrstuvwxyz";static const char* upper_digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";static size_t _strnlen(const char* s, size_t count){ const char* sc; for (sc = s; *sc != '\0' && count--; ++sc); return sc - s;}static int skip_atoi(const char** s){ int i = 0; while (is_digit(**s)) i = i * 10 + *((*s)++) - '0'; return i;}static void number(std_putc putc, long num, int base, int size, int precision, int type){ char c, sign, tmp[66]; const char* dig = digits; int i; char tmpch; if (type & LARGE) dig = upper_digits; if (type & LEFT) type &= ~ZEROPAD; if (base < 2 || base > 36) return; c = (type & ZEROPAD) ? '0' : ' '; sign = 0; if (type & SIGN) { if (num < 0) { sign = '-'; num = -num; size--; } else if (type & PLUS) { sign = '+'; size--; } else if (type & SPACE) { sign = ' '; size--; } } if (type & SPECIAL) { if (base == 16) size -= 2; else if (base == 8) size--; } i = 0; if (num == 0) tmp[i++] = '0'; else { while (num != 0) { tmp[i++] = dig[((unsigned long)num) % (unsigned)base]; num = ((unsigned long)num) / (unsigned)base; } } if (i > precision) precision = i; size -= precision; if (!(type & (ZEROPAD | LEFT))) { while (size-- > 0) { tmpch = ' '; putc(&tmpch, 1); } } if (sign) { putc(&sign, 1); } if (type & SPECIAL) { if (base == 8) { tmpch = '0'; putc(&tmpch, 1); } else if (base == 16) { tmpch = '0'; putc(&tmpch, 1); tmpch = digits[33]; putc(&tmpch, 1); } } if (!(type & LEFT)) { while (size-- > 0) { putc(&c, 1); } } while (i < precision--) { tmpch = '0'; putc(&tmpch, 1); } while (i-- > 0) { tmpch = tmp[i]; putc(&tmpch, 1); } while (size-- > 0) { tmpch = ' '; putc(&tmpch, 1); }}static void log_vsprintf(std_putc putc, const char* fmt, va_list args){ int len; unsigned long num; int base; char* s; int flags; // Flags to number() int field_width; // Width of output field int precision; // Min. # of digits for integers; max number of chars for from string int qualifier; // 'h', 'l', or 'L' for integer fields char* tmpstr = NULL; int tmpstr_size = 0; char tmpch; for (; *fmt; fmt++) { if (*fmt != '%') { if (tmpstr == NULL) { tmpstr = (char*)fmt; tmpstr_size = 0; } tmpstr_size ++; continue; } else if (tmpstr_size) { putc(tmpstr, tmpstr_size); tmpstr = NULL; tmpstr_size = 0; } // Process flags flags = 0;repeat: fmt++; // This also skips first '%' switch (*fmt) { case '-': flags |= LEFT; goto repeat; case '+': flags |= PLUS; goto repeat; case ' ': flags |= SPACE; goto repeat; case '#': flags |= SPECIAL; goto repeat; case '0': flags |= ZEROPAD; goto repeat; } // Get field width field_width = -1; if (is_digit(*fmt)) field_width = skip_atoi(&fmt); else if (*fmt == '*') { fmt++; field_width = va_arg(args, int); if (field_width < 0) { field_width = -field_width; flags |= LEFT; } } // Get the precision precision = -1; if (*fmt == '.') { ++fmt; if (is_digit(*fmt)) precision = skip_atoi(&fmt); else if (*fmt == '*') { ++fmt; precision = va_arg(args, int); } if (precision < 0) precision = 0; } // Get the conversion qualifier qualifier = -1; if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { qualifier = *fmt; fmt++; } // Default base base = 10; switch (*fmt) { case 'c': if (!(flags & LEFT)) { while (--field_width > 0) { tmpch = ' '; putc(&tmpch, 1); } } tmpch = (unsigned char)va_arg(args, int); putc(&tmpch, 1); while (--field_width > 0) { tmpch = ' '; putc(&tmpch, 1); } continue; case 's': s = va_arg(args, char*); if (!s) s = "<NULL>"; len = _strnlen(s, precision); if (!(flags & LEFT)) { while (len < field_width--) { tmpch = ' '; putc(&tmpch, 1); } } putc(s, len); while (len < field_width--) { tmpch = ' '; putc(&tmpch, 1); } continue; case 'p': if (field_width == -1) { field_width = 2 * sizeof(void*); flags |= ZEROPAD; } number(putc,(unsigned long)va_arg(args, void*), 16, field_width, precision, flags); continue; case 'n': continue; case 'A': continue; // Integer number formats - set up the flags and "break" case 'o': base = 8; break; case 'X': flags |= LARGE; case 'x': base = 16; break; case 'd': case 'i': flags |= SIGN; case 'u': break; default: if (*fmt != '%') { tmpch = '%'; putc(&tmpch, 1); } if (*fmt) { tmpch = *fmt; putc(&tmpch, 1); } else { --fmt; } continue; } if (qualifier == 'l') num = va_arg(args, unsigned long); else if (qualifier == 'h') { if (flags & SIGN) num = va_arg(args, int); else num = va_arg(args, uns

用户评论 (0)

发表评论

captcha

相关资源

MATLAB车牌定位实现系统.zip

Matlab车牌识别系统是一个使用Matlab编程语言开发的程序,用来识别汽车车牌上的字符和数字。该系统可以通过读取车牌图像,并使用图像处理、模式识别和机器学习算法来识别和解析车牌上的字符和数字。以下是一个基本的车牌识别系统的工作流程:1. 图像预处理:对车牌图像进行预处理,例如去噪、增强对比度、调整亮度等。2. 车牌定位:使用图像处理算法定位车牌在图像中的位置。3. 字符分割:将车牌图像分割成单个字符,以便对每个字符进行识别。4. 字符识别:使用模式识别或机器学习算法对每个字符进行识别和分类。5. 车牌解析:将识别出的字符组合成完整的车牌号码。6. 输出结果:将识别结果输出到屏幕或保存到文件中。在开发Matlab车牌识别系统时,可以使用Matlab的图像处理工具箱、模式识别工具箱和机器学习工具箱来实现各种功能。此外,还可以使用深度学习模型如卷积神经网络(CNN)来提高字符识别的准确性。可以使用现有的开源深度学习框架(如TensorFlow或PyTorch)来训练和部署深度学习模型,并将其与Matlab集成。总之,Matlab车牌识别系统是一个使用Matl

10.46KB49积分

MATLAB车牌识别完整程序系统

要设计一个基于Matlab的车牌识别系统,可以按照以下步骤进行:1. 数据集准备:收集一组车牌图像作为训练数据集。这些图像应该包含各种不同类型和风格的车牌。2. 图像预处理:对每个图像进行预处理,以提取和增强车牌的特征。可能的预处理步骤包括:图像去噪、图像增强、灰度化、二值化等。3. 车牌定位:使用图像处理技术,如边缘检测、形态学操作等,找到图像中的车牌位置。这可以通过找到车牌的边界框或轮廓来实现。4. 字符分割:对于定位到的每个车牌,对其进行字符分割,将车牌中的每个字符单独提取出来。可以使用基于形态学操作和区域分割的技术来实现。5. 字符识别:对于每个提取出的字符,使用字符识别算法来识别字符的类别。常用的字符识别算法包括基于模板匹配、神经网络、支持向量机等。6. 字符串识别:将识别出的字符组合成一个字符串,作为最终的车牌识别结果。7. 性能评估:使用一组标注好的测试数据集来评估车牌识别系统的性能。可以计算准确率、召回率等指标来评价系统的性能。以上是一个简单的车牌识别系统的设计步骤,可以根据具体情况进行调整和改进。

248.09KB35积分

景区订票系统 JAVA+Vue.js+SpringBoot+MySQL

基于Vue.js和SpringBoot的景区订票系统,分为用户前台和管理后台,可以给管理员、普通用户角色使用,包括景点管理模块、景点留言模块、景点订单模块、论坛管理模块、公告信息模块和系统基础模块,项目编号T297。项目录屏:https://www.bilibili.com/video/BV1Vw4m1k7Cs启动教程:https://www.bilibili.com/video/BV1pW4y1P7GR项目讲解视频:https://space.bilibili.com/417412814/channel/collectiondetail?sid=2242844

29.72MB25积分

c++11多线程-从零基础到手撕线程池

c++11多线程-从零基础到手撕线程池

86.49MB40积分