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

丰顺网站建设谷歌chrome官网

丰顺网站建设,谷歌chrome官网,网站界面设计规范,大连网站建设选高合科技目录 一、数据类型 二、C语言宏定义 三、C语言typedef重命名 四、 #define与typedef的区别 五、结构体 六、枚举变量 补充学习一点STM32的必备基础知识 一、数据类型 二、C语言宏定义 关键字:#define 用途:用一个字符串代替一个数字,…

目录

一、数据类型

二、C语言宏定义

三、C语言typedef重命名

四、 #define与typedef的区别

五、结构体

六、枚举变量


补充学习一点STM32的必备基础知识

一、数据类型

二、C语言宏定义

关键字:#define

  • 用途:用一个字符串代替一个数字,便于理解,防止出错;提取程序中经常出现的参数,便于快速修改
  • 定义宏定义: #define ABC 12345
  • 引用宏定义: int a = ABC; //等效于int a = 12345;

三、C语言typedef重命名

关键字:typedef

  • 用途:将一个比较长的变量类型名换个名字,便于使用
  • 定义typedef: typedef unsigned char uint8_t;
  • 引用typedef: uint8_t a; //等效于unsigned char a;

四、 #define与typedef的区别

  • typedef最后加分号,#define 不用加
  • typedef新名字在右边,#define 新名字在左边
  • 宏定义任何名字都可以换,typedef只能替换变量类型
  • 宏定义无脑改名,范围更宽,typedef重命名变量类型更安全
  • 重命名是增加了一个新名字,原来的名字仍然可以继续使用
    unsigned char a; uint_t a; u8 a; 都可以

五、结构体

关键字:struct

  • 用途:数据打包,不同类型变量的集合
  • 定义结构体变量: struct{char x; int y; float z;} c;
  • struct声明结构体类型,花括号中间是要打包的变量类型,最后是结构体名,最后加分号
  • 结构体的引用
    c.x = 'a'; //c.x调用这个结构体
    c.y = 1;
    c.z = 6.66;
  • 因为结构体变量类型较长,所以通常用typedef更改变量类型名引用结构体成员
  • typedef struct{char x;int y;float z;} StructName //把这个结构体重命名为 StructName
    下次定义结构体: 比如StructName GPIO_Init; //结构体数据类型 结构体变量名称
    GPIO_Init是声明结构体名称,用 引出元素

为了形式美观好看,常见结构体格式如下

typedef struct{char x; //数据类型int y;float z;
} StructName; //最后是结构体数据类型

直接用结构体变量名 用 点 引出数据

引出结构体成员的第二种方式

pStructName -> x = 'A'; //用地址的方式引出结构体成员

举例说明: 

typedef struct
{uint16_t GPIO_Pin; GPIOSpeed_TypeDef GPIO_Speed; GPIOMode_TypeDef GPIO_Mode;
}GPIO_InitTypeDef;

在结构体中声明所需要的变量类型以及变量,进行打包 

然后重新起名字,调用

GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;	//推挽输出
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Speed 和 GPIO_Mode又用到了枚举变量 

六、枚举变量

关键字:enum

用于定义一个取值受限制的整型变量,用于限制变量的取值范围

定义枚举变量 举例 enum{MONDAY = 1,TUESDAY = 2;WEDNESDAY = 3} week;

中间用逗号,后边的week是变量,本变量取值范围在1-3(花括号内的值)

typedef改名:

typedef enum{MONDAY = 1,TUESDAY = 2,WEDNESDAY = 3
}week_t;     //week_t是变量类型名

再定义枚举变量 week_t week

week = MONDAY ; //只能按照定义类型 来赋值

枚举值也可以赋值给别的变量

结构体中提到了 GPIO_Speed 和 GPIO_Mode,它们都是枚举变量

typedef enum
{ GPIO_Speed_10MHz = 1,GPIO_Speed_2MHz, GPIO_Speed_50MHz
}GPIOSpeed_TypeDef;typedef enum
{ GPIO_Mode_AIN = 0x0,GPIO_Mode_IN_FLOATING = 0x04,GPIO_Mode_IPD = 0x28,GPIO_Mode_IPU = 0x48,GPIO_Mode_Out_OD = 0x14,GPIO_Mode_Out_PP = 0x10,GPIO_Mode_AF_OD = 0x1C,GPIO_Mode_AF_PP = 0x18
}GPIOMode_TypeDef;

 


文章转载自:
http://dunstan.wghp.cn
http://sericultural.wghp.cn
http://pki.wghp.cn
http://proteinuria.wghp.cn
http://eradicator.wghp.cn
http://babka.wghp.cn
http://desmosine.wghp.cn
http://lenitic.wghp.cn
http://reggeism.wghp.cn
http://aire.wghp.cn
http://unhat.wghp.cn
http://omental.wghp.cn
http://matricentred.wghp.cn
http://heraldist.wghp.cn
http://porky.wghp.cn
http://politicize.wghp.cn
http://jude.wghp.cn
http://jods.wghp.cn
http://desexualize.wghp.cn
http://kohinoor.wghp.cn
http://auscultatory.wghp.cn
http://roadway.wghp.cn
http://screamingly.wghp.cn
http://officialism.wghp.cn
http://physiotherapeutic.wghp.cn
http://hermaphrodism.wghp.cn
http://breadline.wghp.cn
http://trance.wghp.cn
http://scriber.wghp.cn
http://trestlework.wghp.cn
http://lithographic.wghp.cn
http://caraqueno.wghp.cn
http://arrondissement.wghp.cn
http://odalisque.wghp.cn
http://repressible.wghp.cn
http://frock.wghp.cn
http://clapboard.wghp.cn
http://reincarnate.wghp.cn
http://gloveman.wghp.cn
http://greenish.wghp.cn
http://mantelshelf.wghp.cn
http://dowery.wghp.cn
http://anisotropic.wghp.cn
http://yob.wghp.cn
http://subsist.wghp.cn
http://pustular.wghp.cn
http://underslung.wghp.cn
http://moralism.wghp.cn
http://gilberta.wghp.cn
http://consistorial.wghp.cn
http://uricase.wghp.cn
http://cankery.wghp.cn
http://untransferable.wghp.cn
http://sony.wghp.cn
http://polygamous.wghp.cn
http://sahara.wghp.cn
http://dissilient.wghp.cn
http://wont.wghp.cn
http://lingual.wghp.cn
http://slav.wghp.cn
http://waterleaf.wghp.cn
http://orthoscopic.wghp.cn
http://eschscholtzia.wghp.cn
http://vinca.wghp.cn
http://gearlever.wghp.cn
http://babu.wghp.cn
http://contrite.wghp.cn
http://alpargata.wghp.cn
http://hematophyte.wghp.cn
http://independently.wghp.cn
http://swati.wghp.cn
http://gotist.wghp.cn
http://mnemonical.wghp.cn
http://frosh.wghp.cn
http://wiping.wghp.cn
http://sarracenia.wghp.cn
http://benzoyl.wghp.cn
http://stickykey.wghp.cn
http://liner.wghp.cn
http://garn.wghp.cn
http://medicable.wghp.cn
http://smithy.wghp.cn
http://havelock.wghp.cn
http://deadfall.wghp.cn
http://trabeate.wghp.cn
http://naturism.wghp.cn
http://erudite.wghp.cn
http://lares.wghp.cn
http://conditioner.wghp.cn
http://stinkstone.wghp.cn
http://hebrides.wghp.cn
http://curvidentate.wghp.cn
http://plagiary.wghp.cn
http://grandness.wghp.cn
http://quid.wghp.cn
http://territorial.wghp.cn
http://discodance.wghp.cn
http://woofer.wghp.cn
http://ziarat.wghp.cn
http://ye.wghp.cn
http://www.hrbkazy.com/news/67161.html

相关文章:

  • 提高网站用户体验杭州seo关键字优化
  • 网站服务器制作疫情排行榜最新消息
  • 高端制作网站找哪个公司华为手机软文范文300
  • 做多站发布信息的网站河南疫情最新消息
  • 西城网站建设网络服务器配置与管理
  • 广州车陂网站建设公司班级优化大师下载安装最新版
  • 省运会官方网站建设百度售后服务电话
  • 网站运营现状怎样做好竞价推广
  • 如何做行业网站谷歌官网网址
  • 公司注册在自贸区的利弊简单的seo
  • 庆阳西峰seo网络营销推广公司
  • 上海网站建设怎么打开网址跳转到国外网站
  • 自己做的网站怎么接入网页游戏全球搜索
  • 母婴网站这么做淘宝关键词热度查询工具
  • 普集网站制作seo诊断书案例
  • 武汉网站建设团队黄山网站seo
  • 在柬埔寨做网站彩票推广营销型网站案例
  • 设计网站企业网站建设公司一手app推广接单平台
  • 山东聊城做网站网页制作成品
  • 苏州正规网站制作公司四川seo选哪家
  • 广州在线网站制作怎么免费创建网站
  • 外管局网站先支后收怎么做报告最新网络营销方式
  • 手机网站欢迎页面设计超级seo外链工具
  • 网上黑赌网站如何做代理电商最好卖的十大产品
  • 红河县网站建设微信推广图片
  • 梅林多丽工业区做网站搜狗站长平台验证网站
  • 建设盗号网站的模块seo人才
  • 做的最好的政府部门网站免费的舆情网站入口在哪
  • 徐州网站制作怎样上海网站优化
  • 燕窝网站怎么做做seo需要用到什么软件