简体   繁体   English

如何在 C# 中写入 sbit

[英]How do I write sbit in C#

I am porting c code of a firmware to c# and not sure how this keyword我正在将固件的 c 代码移植到 c# 并且不确定这个关键字如何

"sbit"

can be written in c#.可以写成c#。 Thanks in advance.提前致谢。

link @Ben Robinson,链接@Ben Robinson,

"(...)With typical 8051 applications, it is often necessary to access individual bits within an SFR. The sbit type provides access to bit-addressable SFRs and other bit-addressable objects. For example: “(...)对于典型的 8051 应用程序,通常需要访问 SFR 中的各个位。sbit 类型提供对位可寻址 SFR 和其他位可寻址对象的访问。例如:

sbit EA = 0xAF;

This declaration defines EA as the SFR bit at address 0xAF.该声明将 EA 定义为地址 0xAF 处的 SFR 位。 On the 8051, this is the enable all bit in the interrupt enable register.(...)".在 8051 上,这是中断启用寄存器中的启用所有位。(...)"。

sbit name = sfr-address ^ bit-position;

This too low level, you might try to use c++.net, for that matter.这个级别太低了,你可能会尝试使用 c++.net。 C# is a high level language, using pointers can be a little tricky, it can be done, but escapes from c# real intent. C# 是一种高级语言,使用指针可能有点棘手,可以做到,但从 c# 的真正意图中逃脱。
You could use c++.net made functions, as the final code of both is the same [clr (Common Language Run-Time)], the machine will not note the diference.您可以使用 c++.net 制作的函数,因为两者的最终代码是相同的 [clr (Common Language Run-Time)],机器不会注意到差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM