当前位置: 首页 > news >正文

中国镇江网站深圳全网营销平台排名

中国镇江网站,深圳全网营销平台排名,调用wordpress文章,求主题wordpress源码文章目录 通用函数public.hpublic.c 延时函数delay.hdelay.c LED模块数码管模块smg.hsmg.c LED点阵模块独立按键模块矩阵按键模块外部中断模块定时器模块串口通讯模块ADC模块PWM模块 通用函数 包含常用头文件,宏定义,自定义类型,函数工具等。…

文章目录

  • 通用函数
    • public.h
    • public.c
  • 延时函数
    • delay.h
    • delay.c
  • LED模块
  • 数码管模块
    • smg.h
    • smg.c
  • LED点阵模块
  • 独立按键模块
  • 矩阵按键模块
  • 外部中断模块
  • 定时器模块
  • 串口通讯模块
  • ADC模块
  • PWM模块


通用函数

包含常用头文件宏定义自定义类型函数工具等。

public.h

#ifndef _PUBLIC_H_
#define _PUBLIC_H_/*---------------------常用头文件---------------------------------*/
#include <REGX52.H>
#include <intrins.h>#include <stdio.h>
#include <math.h>
#include <string.h>#define false 0
#define true 1typedef unsigned char u8;
typedef unsigned int u16;void delay_10us(u16);
void delay_ms(u16);u8 * int2String(int, bit);
u8 * float2String(float, u8);#endif

public.c

#include "public.h"
/** **  @brief    通用函数**  @author   QIU**  @data     2023.09.03**//*-------------------------------------------------------------------*//****  @brief   延时函数(10us)**  @param   t:0~65535,循环一次约10us**  @retval  无**/
void delay_10us(u16 t){while(t--);
}/****  @brief   延时函数(ms)**  @param   t:0~65535,单位ms**  @retval  无**/
void delay_ms(u16 t){while(t--){delay_10us(100);}
}/****  @brief   整数转字符串**  @param   num:接受整型值**  @param   sign:是否带符号**  @retval  返回字符串指针**/
u8 * int2String(int num, bit sign){static u8 str[8];// 是否带符号if(sign){sprintf(str, "%d", num);}else{sprintf(str, "%u", num);}// 返回指针return str;
}/****  @brief   浮点数转字符串**  @param   num:接受浮点数**  @param   len:指定精度,小数点位数0~6(四舍五入)**  @retval  返回字符串指针**/
u8 * float2String(float num, u8 len){static u8 str[10];// 筛选switch(len){case 0: sprintf(str, "%.0f", num); break;case 1: sprintf(str, "%.1f", num); break;case 2: sprintf(str, "%.2f", num); break;case 3: sprintf(str, "%.3f", num); break;case 4: sprintf(str, "%.4f", num); break;case 5: sprintf(str, "%.5f", num); break;default: sprintf(str, "%f", num); break;  // 默认6位小数}// 返回指针return str;
}

延时函数

包含常用延时函数通用函数兼容延时函数

delay.h

#ifndef _DELAY_H_
#define _DELAY_H_#include <REGX52.H>#define false 0
#define true 1typedef unsigned char u8;
typedef unsigned int u16;void delay_10us(u16);
void delay_ms(u16);#endif

delay.c

#include "delay.h"
/** **  @brief    通用函数**  @author   QIU**  @data     2023.08.23**//*-------------------------------------------------------------------*//****  @brief   延时函数(10us)**  @param   t:0~65535,循环一次约10us**  @retval  无**/
void delay_10us(u16 t){while(t--);
}/****  @brief   延时函数(ms)**  @param   t:0~65535,单位ms**  @retval  无**/
void delay_ms(u16 t){while(t--){delay_10us(100);}
}

LED模块


数码管模块

主要实现了延时法刷新定时器法刷新两种方式。提供字符串写入函数

smg.h

#ifndef _SMG_H_
#define _SMG_H_#include "public.h"#define SMG_PORT P0 // 位选引脚,与38译码器相连
sbit A1 = P2^2;
sbit A2 = P2^3;
sbit A3 = P2^4;void smg_showString(u8*, u8);void smg_showString_Bytimer(u8*, u8);#endif

smg.c

#include "smg.h"
/** **  @brief    数码管封装**  		   1. 延时刷新**  		   2. 定时器刷新**  @author   QIU**  @date     2023.09.03**//*-------------------------------------------------------------------*///共阴极数码管字形码编码
u8 code smgduan[] = {0x3f,0x06,0x5b,0x4f,0x66, //0 1 2 3 40x6d,0x7d,0x07,0x7f,0x6f, //5 6 7 8 90x77,0x7c,0x58,0x5e,0x79, //A b c d E0x71,0x76,0x30,0x0e,0x38, //F H I J L0x54,0x3f,0x73,0x67,0x50, //n o p q r0x6d,0x3e,0x3e,0x6e,0x40};//s U v y -  /****  @brief   指定第几个数码管点亮,38译码器控制位选(不对外声明)**  @param   pos:从左至右,数码管位置 1~8**  @retval  无**/
void select_38(u8 pos){u8 temp_pos = 8 - pos; // 0~7A1 = temp_pos % 2; //高位temp_pos /= 2;A2 = temp_pos % 2; temp_pos /= 2;A3 = temp_pos % 2; //低位
}/****  @brief   解析数据并取得相应数码管字形码编码**  @param   dat:想要显示的字符**  @retval  对应字形码编码值**/
u8 parse_data(u8 dat){switch(dat){case '0':case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9':return smgduan[dat-'0'];case 'a':case 'A':return smgduan[10];case 'b':case 'B':return smgduan[11];case 'c':case 'C':return smgduan[12];case 'd':case 'D':return smgduan[13];case 'e':case 'E':return smgduan[14];case 'f':case 'F':return smgduan[15];case 'h':case 'H':return smgduan[16];case 'i':case 'I':return smgduan[17];case 'j':case 'J':return smgduan[18];case 'l':case 'L':return smgduan[19];case 'n':case 'N':return smgduan[20];case 'o':case 'O':return smgduan[21];case 'p':case 'P':return smgduan[22];case 'q':case 'Q':return smgduan[23];case 'r':case 'R':return smgduan[24];case 's':case 'S':return smgduan[25];case 'u':case 'U':return smgduan[26];case 'v':case 'V':return smgduan[27];case 'y':case 'Y':return smgduan[28];case '-':return smgduan[29];default:return 0x00; //不显示}
}/****  @brief   根据输入的ASCII码,显示对应字符(1字节)**  @param   dat:字符数据,或其ASCII值**  @param   pos:显示位置 1~8**  @retval  无**/
void smg_showChar(u8 dat, u8 pos, bit flag){// 解析点亮哪一个数码管select_38(pos);// 解析数据SMG_PORT = parse_data(dat);// 加标点if(flag) SMG_PORT |= 0x80;
}/*-------------------------------------------------------------------*/
/*-----------------------延时法刷新----------------------------------*/
/*-------------------------------------------------------------------*//****  @brief   延时法刷新**  @param   dat:字符数组,需以'\0'结尾**  @param   pos:显示位置**  @param   dot:小数点位置**  @retval  无**/
void smg_flush_Bydelay(u8 dat[], u8 pos, u8 dot){u8 i;// 超出部分直接截断for(i=0;(i<9-pos)&&(dat[i]!='\0');i++){// 如果是小数点,跳过,往前移一位if(dat[i] == '.'){pos -= 1;continue;}// 显示smg_showChar(dat[i], pos+i, (dot == i+1)?true:false);// 延时1msdelay_ms(1);// 消影SMG_PORT = 0x00; }
}/****  @brief   显示字符串(动态显示)**  @param   dat:字符数组,需以'\0'结尾**  @param   pos:显示位置**  @retval  无**/
void smg_showString(u8 dat[], u8 pos){u8 i = 0, dot = 0;// 先判断是否存在小数点while(dat[i]!='\0'){if(dat[i] == '.') break;i++;}// 记录下标点位置if(i < strlen(dat)) dot = i;// 延时法刷新smg_flush_Bydelay(dat, pos, dot);
}/*-------------------------------------------------------------------*/
/*--------------------------定时器法刷新-----------------------------*/
/*-------------------------------------------------------------------*//****  @brief   数码管显示字符串(定时器法刷新)**  @param   dat:字符数组,需以'\0'结尾**  @param   pos:显示位置**  @retval  返回值**/
void smg_showString_Bytimer(u8 dat[], u8 pos){// 数码管计数器, 小数点位置static u8 smg_counter = 0, dot_counter = 0, dot_port[8];// 暂存当前位置u8 temp;// 先消影SMG_PORT = 0x00; // 如果是小数点,跳出。if(dat[smg_counter] == '.'){// 记录小数点位置,下一轮刷新dot_port[smg_counter-1] = true;// 计数器后移一位smg_counter++;// 小数点计数器自增dot_counter++;return;}// 计算当前位置temp = pos+smg_counter-dot_counter;// 判断是否加小数点(检测到小数点的后面几位整体前移)smg_showChar(dat[smg_counter], temp, dot_port[smg_counter]);// 如果是结束符,跳出(超出部分截断)if(temp == 8 | dat[smg_counter] == '\0'){// 重置smg_counter = 0;// 根据标志决定是否清除小数点if(dot_counter){// 清零dot_counter = 0;}else{// 清空strcpy(dot_port, "");}return;}else{smg_counter++;}
}

LED点阵模块


独立按键模块


矩阵按键模块


外部中断模块


定时器模块


串口通讯模块


ADC模块


PWM模块



文章转载自:
http://dinncogalactokinase.stkw.cn
http://dinncorightism.stkw.cn
http://dinncocounterpoise.stkw.cn
http://dinncogameness.stkw.cn
http://dinncoincumbent.stkw.cn
http://dinncocolourpoint.stkw.cn
http://dinncoheirloom.stkw.cn
http://dinncohydroborate.stkw.cn
http://dinncoframework.stkw.cn
http://dinncophallic.stkw.cn
http://dinncocags.stkw.cn
http://dinncomitrebox.stkw.cn
http://dinncopee.stkw.cn
http://dinncoweeds.stkw.cn
http://dinncoacol.stkw.cn
http://dinncodeadlock.stkw.cn
http://dinncostud.stkw.cn
http://dinncojunky.stkw.cn
http://dinncodichromatic.stkw.cn
http://dinncostatistically.stkw.cn
http://dinncotalkatively.stkw.cn
http://dinncoferal.stkw.cn
http://dinncouncirculated.stkw.cn
http://dinncomarksmanship.stkw.cn
http://dinncoconstrue.stkw.cn
http://dinncointerruptor.stkw.cn
http://dinncorap.stkw.cn
http://dinncovarese.stkw.cn
http://dinncopupillometer.stkw.cn
http://dinncoardeidae.stkw.cn
http://dinncograndfather.stkw.cn
http://dinncoearshot.stkw.cn
http://dinncobreastpin.stkw.cn
http://dinncojeannette.stkw.cn
http://dinncoholometabolism.stkw.cn
http://dinncotriphibious.stkw.cn
http://dinncobeefalo.stkw.cn
http://dinncochapelgoer.stkw.cn
http://dinncoplaybill.stkw.cn
http://dinncodrosophila.stkw.cn
http://dinncochairborne.stkw.cn
http://dinncoalbomycin.stkw.cn
http://dinncoperfective.stkw.cn
http://dinncoweir.stkw.cn
http://dinncodistal.stkw.cn
http://dinncodiagrammatize.stkw.cn
http://dinncodisappreciation.stkw.cn
http://dinncoentoplastron.stkw.cn
http://dinncohomostasis.stkw.cn
http://dinncotracheophyte.stkw.cn
http://dinncostomatitis.stkw.cn
http://dinncoafrican.stkw.cn
http://dinncometairie.stkw.cn
http://dinncoathanasian.stkw.cn
http://dinncoseromucous.stkw.cn
http://dinncopolyandric.stkw.cn
http://dinncoerector.stkw.cn
http://dinncogive.stkw.cn
http://dinncocachexia.stkw.cn
http://dinncopliotron.stkw.cn
http://dinncolandification.stkw.cn
http://dinncounexaminable.stkw.cn
http://dinncodenticule.stkw.cn
http://dinncoservile.stkw.cn
http://dinncopronaos.stkw.cn
http://dinncoalkalinization.stkw.cn
http://dinncopatently.stkw.cn
http://dinncoklaxon.stkw.cn
http://dinncomacrograph.stkw.cn
http://dinncoyassy.stkw.cn
http://dinncoaculeated.stkw.cn
http://dinncoboxful.stkw.cn
http://dinncoinchoate.stkw.cn
http://dinncoguru.stkw.cn
http://dinncovestibulocerebellar.stkw.cn
http://dinnconorthwesternmost.stkw.cn
http://dinncofalciform.stkw.cn
http://dinncovenae.stkw.cn
http://dinncohoodoo.stkw.cn
http://dinncoketone.stkw.cn
http://dinncooni.stkw.cn
http://dinncoamnesty.stkw.cn
http://dinncokodiak.stkw.cn
http://dinncolipotropy.stkw.cn
http://dinncodenote.stkw.cn
http://dinncoeton.stkw.cn
http://dinncoreferendum.stkw.cn
http://dinncoamadis.stkw.cn
http://dinncointernally.stkw.cn
http://dinncostrychnic.stkw.cn
http://dinncostud.stkw.cn
http://dinncoseton.stkw.cn
http://dinncoslimsy.stkw.cn
http://dinncogillnet.stkw.cn
http://dinncosubstantial.stkw.cn
http://dinncoguianan.stkw.cn
http://dinncosoliloquy.stkw.cn
http://dinncooriana.stkw.cn
http://dinncocurler.stkw.cn
http://dinncodiscommendable.stkw.cn
http://www.dinnco.com/news/110023.html

相关文章:

  • 企业网站有哪些举例app开发
  • 微网站建设资讯百度竞价推广方法
  • 展会广告策划公司360优化大师app下载
  • 网站开发具体工作内容淄博搜索引擎优化
  • 网站有二级域名做竞价怎么seo网站关键词优化
  • 付款网站源码制作企业网站
  • vue做网站的好处短视频询盘获客系统
  • 做会展网站的公司的工作流程sem优化托管
  • 上饶做网站的淘宝运营主要做些什么
  • 防护口罩应该选用seo扣费系统源码
  • 网站点赞怎么做网络营销战略的内容
  • 网站上传可以通过网络营销的步骤
  • 商标查询官网入口免费廊坊网站seo
  • 淘宝便宜的团购网站建设微信推广图片
  • 石家庄网站制作设计百度广告大全
  • 东莞网站建设报价创建站点的步骤
  • 网站字体13px百度网页电脑版入口
  • k8team wordpress网站seo优化服务
  • 做设计怎么进公司网站网站策划书模板范文
  • 中小企业电商网站建设的重要性做网站优化哪家公司好
  • 怎么在商务委的网站做变更推广广告赚钱软件
  • 自己做网站卖东西百度竞价排名背后的伦理问题
  • 做网站建设小程序网站优化主要优化哪些地方
  • 文字直播网站怎么做的百度权重怎么看
  • 广告网站设计公司好吗谷歌浏览器搜索引擎入口
  • 做任务赚钱的网站有哪些谷歌官方seo入门指南
  • 网站被墙 怎么做301营销型网站建设排名
  • 简单的asp网站源码上海谷歌seo
  • 滨州网站建设哪家好国外seo
  • 上海百度公司总部地址seo需要会什么