Page 386 - Programming Microcontrollers in C
P. 386

The Monitor Program     371

                          file and certain lines of the file will be included or excluded depending
                          on the definition of this parameter.
                              It is intended to store the data in a linked list in memory. The
                          linked list will have a node called an Entry. An Entry contains two
                          characters that will be indices into the data array. The first member is
                          the index to the data in the data array. The second member is an index
                          to the next Entry for the next data entry. An array of 35 Entrys will
                          be stored in EEPROM along with an array of 698 (=768–35*2) chars
                          to store the nonvolatile data. There are 768 bytes of EEPROM on the
                          particular M68HC912B32 chip that we are using here.
                              A structure type named Epro is created to hold the collections
                          of Entrys and the remaining data for the data storage area. This
                          structure will be forced to the address 0xd00 at link time. It will
                          also be identified as EEPROM so that assignments to this memory
                          area will compile to storage to EEPROM rather than writes to normal
                          data memory. The first three entries in the data[] array are devoted
                          to special uses. data[0] contains the next open index into the
                          data[] array, data[1] contains an index to the beginning of the
                          list and data[2] contains the number of entries in the list. To
                          simplify both the code writing and remembering of the uses of these
                          memory locations, I used macros to define useful names for these
                          locations. Also included here is an old favorite, the FOREVER loop.
                   #define DOS
                   #ifndef PHONE_H
                   #define PHONE_H

                   #ifdef DOS
                   #include <stdio.h>
                   typedef unsigned int WORD;
                   enum Bool{FALSE,TRUE};
                   #define FOREVER while(TRUE)
                   #endif

                   #include <stdlib.h>
                   #include <string.h>

                   typedef struct {
                        unsigned dataindex;
   381   382   383   384   385   386   387   388   389   390   391