简体   繁体   中英

How do I write sbit in C#

I am porting c code of a firmware to c# and not sure how this keyword

"sbit"

can be written in c#. Thanks in advance.

link @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:

sbit EA = 0xAF;

This declaration defines EA as the SFR bit at address 0xAF. On the 8051, this is the enable all bit in the interrupt enable register.(...)".

sbit name = sfr-address ^ bit-position;

This too low level, you might try to use c++.net, for that matter. C# is a high level language, using pointers can be a little tricky, it can be done, but escapes from c# real intent.
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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