Professional Documents
Culture Documents
reg52.h
GLOBAL.h
PORT Definition
Frequency
Primitive Type
PC_IO.c
#define RECV_BUFF_LEN 8
// private constants
#define Private_Macro_Function(x) _B(x)
// private macro
staic tByte Recv_buffer[RECV_BUFF_LEN];
// private variable definitions
staic void PC_LINK_IO_Send_Char(const char);
// private function prototypes
//-------------------------------------------------------------------------------------------#define _B(X) _B(x)_Implementation
// private marco implement
tByte In_read_index_G;
// public variable definitions
void PC_LINK_IO_Update(void) { ... }
// function implemtation
void PC_LINK_IO_Send_Char(const char) { ... }
[Storage-class specifier] EXTERN (auto, register, static, extern, typedef)
An external variable must be defined, exactly once, outside of any function; this sets aside
storage for it. The variable must also be declared in each function that wants to access it
Before a function can use an external variable, the name of the variable must be made
known to the function; the declaration is the same as before except for the added keyword
extern.
In certain circumstances, the extern declaration can be omitted. If the definition of the
MAIN.h function, then there
external variable occurs in the source file before its use in a particular
is no need for an extern declaration in the function.
-memberName
In fact, common practice is to place definitions of all external variables
at the beginning of
-memberName
the source file, and then omit all extern
declarations.
MAIN.c
#include MAIN.h
#include CPCMD.h
CPCMD.h
-memberName
-memberName
CPCMD.c
#include CPMD.h
#include I2C.h
UART.h
-memberName
-memberName
UART.c
#include UART.h
I2C.h
-memberName
-memberName
I2C.c
#include I2C.h