Microcontroller-C language-definition and declaration

Source: Internet
Author: User

The following code is a single-chip microcomputer program, 51 microcontroller, compiler for ht-ide3000,

Simply put,

Can only be stated in the header file,

When the variable is declared in the header file, add the extern keyword to tell the compiler that the variable is defined in other files,

Enum is not a variable, it is a data type we define ourselves, like int char, but we define it ourselves, so we don't have to add it.

1 externU16 G_u16timebasecount;2 externU8 g_8count_2s;3 externU8 g_8count_8s;4 externU8 g_8count_18s;5 externU8 g_8count_60s;6 externU8 g_8count_200s;7 externU8 g_8count_6h;8 externU8 G_8COUNT_200SW;//6hour Wash9 externU8 G_8COUNT_6HW;//6hour WashTen externU8 W_6hw_start; One externU8 W_6hw_end; A externU8 G_state; - externU16 Make_6h_count; - externU8 g_once; the externU16 S_C1;//Intermediate Variables - externU16 S_C2; - externU16 S_C3; - externU16 S_C4; +  - externU8 uartreceive; + externU8 ad[6]; A externU8 tds[6]; at externU8 Count_ad;  - externU8 Count_ads;  - externU16 Sumtds_h,sumtds_l,sum; - externU16 Temer; -  -typedefenumGpiopin in { -Gpio_pin_0 = ((U8)0x01),/*!< Pin 0 selected*/ toGpio_pin_1 = ((U8)0x02),/*!< Pin 1 selected*/ +Gpio_pin_2 = ((U8)0x04),/*!< Pin 2 selected*/ -Gpio_pin_3 = ((U8)0x08),/*!< Pin 3 selected*/ theGpio_pin_4 = ((U8)0x10),/*!< Pin 4 selected*/ *Gpio_pin_5 = ((U8)0x20),/*!< Pin 5 selected*/ $Gpio_pin_6 = ((U8)0x40),/*!< Pin 6 selected*/Panax NotoginsengGpio_pin_7 = ((U8)0x80),/*!< Pin 7 selected*/ -gpio_pin_lnib = ((U8)0x0F),/*!< Low nibble pins selected*/ thegpio_pin_hnib = ((U8)0xF0),/*!< High Nibble pins selected*/ +Gpio_pin_all = ((U8)0xFF)/*!< All pins selected*/ A}gpio_pin_typedef;

function is also in the header file, can only declare, cannot add function body

U8 uart_receive ();

The implementation of variables and functions is also the function body, which can only be defined in the source file.

1 UFLG Uf1,uf2,uf3,uf4;2 U16 G_u16timebasecount;3 U8 g_8count_2s;4 U8 g_8count_8s;5 U8 g_8count_18s;6 U8 g_8count_60s;7 U8 g_8count_200s;8 U8 g_8count_6h;9U8 G_8COUNT_200SW;//6hour WashTenU8 G_8COUNT_6HW;//6hour Wash One U8 W_6hw_start; A U8 W_6hw_end; - U8 G_state; - U16 Make_6h_count; the U8 g_once; -U16 S_C1;//Intermediate Variables - U16 S_C2; - U16 S_C3; + U16 S_C4; -U8 uartreceive=0; +U8 ad[6]={0,0,0,0,0,0}; AU8 tds[6]={0,0,0,0,0,0}; atU8 count_ad=0;  -U8 count_ads=0;  -U16 Sumtds_h=0, sumtds_l=0, sum=0; - U16 Temer; -  - //=========================== Data Reception =========================================// in U8 uart_receive () -     { to U8 data; +        if(_rxif==1)//If the data is received -        { theData=_TXR_RXR; *              returndata; $            }Panax Notoginseng}

Microcontroller-C language-definitions and declarations

Related Article

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.