[英]Size of _SFR_IO_ADDR() result in AVR GCC
I am in a situation where I need to save addresses of IO ports to variables. 我处于一种需要将IO端口的地址保存到变量的情况下。
I've found that eg. 我发现例如。
_SFR_IO_ADDR(PORTB)
gives address of PORTB. _SFR_IO_ADDR(PORTB)
给出PORTB的地址。
What data type do I need to reliably contain the result of this macro? 我需要哪种数据类型来可靠地包含此宏的结果? Will
uint8_t
suffice? uint8_t
足够?
(I tried to google it, found nothing - sorry.) (我尝试用Google搜索它,什么都没找到-对不起。)
The easiest way to do it is to just use a pointer. 最简单的方法是只使用一个指针。 GCC will Do The Right Thing .
GCC将做正确的事 。
volatile char *pb = &PORTB;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.