当前位置:网站首页>Application of C language bit field -- storing eight flag bits in one byte
Application of C language bit field -- storing eight flag bits in one byte
2022-04-22 19:57:00 【RYYB】
/* define.h */
typedef struct {
unsigned char bit0 :1;
unsigned char bit1 :1;
unsigned char bit2 :1;
unsigned char bit3 :1;
unsigned char bit4 :1;
unsigned char bit5 :1;
unsigned char bit6 :1;
unsigned char bit7 :1;
}_STC_BIT;
#define DEF_BIT7(pdata) ((volatile _STC_BIT*)(pdata))->bit7
#define DEF_BIT6(pdata) ((volatile _STC_BIT*)(pdata))->bit6
#define DEF_BIT5(pdata) ((volatile _STC_BIT*)(pdata))->bit5
#define DEF_BIT4(pdata) ((volatile _STC_BIT*)(pdata))->bit4
#define DEF_BIT3(pdata) ((volatile _STC_BIT*)(pdata))->bit3
#define DEF_BIT2(pdata) ((volatile _STC_BIT*)(pdata))->bit2
#define DEF_BIT1(pdata) ((volatile _STC_BIT*)(pdata))->bit1
#define DEF_BIT0(pdata) ((volatile _STC_BIT*)(pdata))->bit0
/* xxx.h */
extern unsigned char status;
...
#define flag_xx4 DEF_BIT4(&status)
#define flag_xx3 DEF_BIT3(&status)
#define flag_xx2 DEF_BIT2(&status)
#define flag_xx1 DEF_BIT1(&status)
#define flag_xx0 DEF_BIT0(&status)
The above is from Reza demo.
perhaps :
union {
struct {
uint8_t flag_xx0 : 1;
uint8_t flag_xx1 : 1;
uint8_t flag_xx2 : 1;
uint8_t flag_xx3 : 1;
uint8_t rsv : 4;
}flag;
uint8_t flags;
}
版权声明
本文为[RYYB]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221955221338.html
边栏推荐
- 2022-01-12 微信小程序调试
- 怎么才能申购可转债呢?申购可转债安全吗?
- Is it better to do operation or software testing?
- Biography: Ali Dharma Institute layoffs 30%! Internal staff: rumors! Netizen: why not cut 29.99%...
- x16为什么比x8慢?
- 2021应届毕业生该何去何从?
- 5篇关于强化学习在金融领域中应用的论文推荐
- [eight part essay] redis cache
- [program source code] graduation project - second-hand trading website
- calico官网网络拓扑实现:基于eNSP与VMVare
猜你喜欢

envoy代理后获取客户端真实IP

为什么说PuddingSwap或许为成为GameFi领域的一匹强势黑马?

树的那些破事~模板小结

【H5】微信端H5页面制作

STM32 learning record 006 - new project template (based on firmware library)
![[eight part essay] redis cache](/img/a2/ec1b1b7b27692d1c55d1bbf1138f9f.png)
[eight part essay] redis cache
![[AI vision · quick review of NLP natural language processing papers today, issue 33] Thu, 21 APR 2022](/img/29/ea8122c1afeaa382d6c7b6de3b04d2.png)
[AI vision · quick review of NLP natural language processing papers today, issue 33] Thu, 21 APR 2022

Why do I suggest you work in a technical position instead of a clerical position, sales

Read the visual public chain of Hoo smart chain

一百多天,0基础自学转行软件测试,从月薪3000到15k,我整理的超全学习指南
随机推荐
【八股文】Redis缓存
行业趋势远比努力更重要--顶测科技总结
2022-01-12 微信小程序调试
The origin explanation and use example of image pre training model
Is it better to do operation or software testing?
Selenium automatic pop-up processing
Where should 2021 fresh graduates go?
【牛客刷题19】MP3光标位置
[leetcode daily question] rotation function
Is it true to download the financial app of qiniu business school? Is it safe to open an account in qiniu
DNS资源记录详解&权威|递归解析区别(超细致)
Uniapp product category tab
Hard work alone is not enough! And this
使用ldap客户端创建zimbra ldap用户的格式
Firewalld DBUS interface usage guide
Biography: Ali Dharma Institute layoffs 30%! Internal staff: rumors! Netizen: why not cut 29.99%...
【2022应届生看过来】一个无经验的大学毕业生,可以转行做软件测试吗?
Lithography giant ASML broke the news: the chip is too short, and they are starting to dismantle the washing machine!
海康内置4G卡的摄像头设备无法注册EasyCVR平台是什么原因?
Embedded Web project (I) -- introduction of web server