First create a common point H file, add the common code as follows
typedef union{ struct { unsigned char b0:1; unsigned char b1:1; unsigned char b2:1; unsigned char b3:1; unsigned char b4:1; unsigned char b5:1; unsigned char b6:1; unsigned char b7:1; } Bits;} Uint8_val;
General definition when the union is written, to define a flag bit that occupies only a byte, simply define the Uchar byte and then refer to one of its members.
For example, define a consortium in C file, add code
Uint8_val BitFlag1 = {0x00};//Each bit is initialized to 0 if 1 is available for a location BITX
Well, define a BITFLAG1 union, if you want to reference one of the bit flags in another point C file, just declare it outside the point H file, as shown in the following code
--------------------bit variable declaration--------------------------extern uint8_val BitFlag1; #define t1msflagbitflag1.bits.b0//Task 1
The Union BITFLAG1 is declared externally, and the macro defines one of the bits t1msflag as the lowest byte in the union, and in other C files It is possible to perform Boolean read and write operations directly on the T1msflag.
IAR environment definition bit variable flag bit STM8 MSP430 Universal