IAR environment definition bit variable flag bit STM8 MSP430 Universal

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.