Page 229 - Programming Microcontrollers in C
P. 229
214 Chapter 5 Programming Large 8-Bit Systems
#ifndef NULL
#define NULL (void *)0
enum {FALSE,TRUE};
enum {STOP,START};
enum {OFF,ON};
#define FOREVER while(TRUE)
typedef unsigned int WORD;
typedef unsigned char BYTE;
#endif
#endif
The first instruction in the file is
#ifndef HC11E9
#define HC11E9
and the last entry in the file is
#endif
These lines of code are useful to prevent multiple definitions of the
items defined within the file. If the header file has not been previously
compiled as a part of the program when the above statement is seen,
HC11E9 will not be defined. The first instruction determines if HC11E9
is not defined, and if it is not, the second line defines it. Then all of the
code until the matching #endifwill be compiled. If HC11E9is already
defined, then the compiler will skip the code lines until the matching
#endif is found. Therefore, the programmer can put an
#include <hc11E9.h>
at the beginning of each program module, and it will be used in the
program only once even if several modules are combined into one
and the above statement is included several times in a single file.
This approach is convenient because it allows each module to be
compiled and tested and then the several modules can be merged and
compiled as a unit without worry about multiply defined variables
and values found in header file.
The file next entry is a simple typedef and declaration of a
structure called Register. This structure contains eight 1-bit entries.
Each of these bits corresponds to a specific bit in a register field, and