2020ok  Directory of FREE Online Books and FREE eBooks

Free eBooks > Computers & Internet > Hardware > Microprocessors & System Design > Embedded Systems > Reusable Software Components: Object-Oriented Embedded Systems Programming in C

Reusable Software Components: Object-Oriented Embedded Systems Programming in C

by Truman T. Van Sickl

Download Book

If you are the author or the publisher, and would like to link to your site here, please contact us.

About Book

The publisher, Prentice-Hall ECS Professional
Shows how many object-oriented programming techniques can be used to enhance real-time embedded systems written in C. Reusable Software Components helps real-time embedded systems designers combine the development benefits of the widely-used C language and object-oriented techniques not normally associated with C. It introduces object-oriented programming to microcontroller programmers familiar with C, shows how objects can be written in C, and developed into classes. The book presents useful objects and classes for microcontroller programs, including a class that creates instances of an asynchronous serial port. It also shows how to implement components to handle timer functions and input capture. Data sheets are compiled for all components derived throughout the book. For programmers working with real-time embedded systems.

From the Inside Flap
This book introduces you to new and useful techniques of programming microcontrollers with the high-level language C. The concept of reusable components evolved from research aimed at object-oriented programming for microcontrollers in C. It was found that classes written in C can be packaged as components for easy reuse and modification needed to extend their capability.

In this book you will learn how to create classes in C. Instances of these classes are objects, and within the limits of the microcontroller and other peripherals, as many instances of these objects as are needed can be created. We call these classes components. Such software components have advantages over the corresponding hardware components. In the construction of components, we can apply the concepts of inheritance and polymorphism. Inheritance allows extension of the basic component to meet new requirements without modification of the basic class code. Polymorphism, or late binding, permits the program to select one of several alternative functions or methods. The choice of which to execute cannot be determined until run time. It will be found that careful application of polymorphism can allow a saving of program code.

One of the features of any high-level language is to implement an abstraction in which the underlying computer seemingly disappears. The total programmer interface with the computer is through the language. Often, the basic nature of the computer being programmed is of little concern to the programmer. True for the computer, but untrue for the peripherals. Most of the skill needed to program microcontrollers with a high-level language involves the efficient coding of the interface between the main computer and its program with the peripherals of the system. The code in this book is for an M68HC16 family part. This code is also usable on the M68300 series of components. The main difference will be that the initialization of the core computers is slightly different, and since most peripherals are common between the chips, the only header file change needed will be the basic core part header. The microcontroller code contained in this book, where possible, has been compiled and tested in an M68300 component.

Chapter 1 contains a very brief summary of object-oriented programming (OOP). The main purpose of the chapter is to introduce some of the language of OOP, how classes and objects are used, what to expect from inheritance and virtual functions, and the many limitations of C as OOP language.

Objects written in C are explored in Chapter 2. Here we start with the simplest concept of an object and develop it into a class. We make a class that can support multiple instantiations of itself in the form of different objects. Inheritance is examined and implemented. We then see how virtual functions can be implemented and used. Finally, several mechanisms to improve the appearance, maintainability, and size of the code written with these techniques are shown. All the code in Chapter 2 is written for a DOS-based machine. The code in the remainder of the book is written for the MC68HC16Y1 microcontroller.

The contents of Chapter 3 show the development of several useful objects for microcontroller programs. Here the classes cover some typical data structure classes that can be used in your programs. These data structures have been developed to meet a programming need for some embedded system.

In Chapter 4 we develop a class that creates instances of an asynchronous serial port. This serial port driver is interrupt-controlled and block-oriented. Its implementation is object-oriented. Instances of serial port objects can be created, and with proper care by the basic program, these instances can be run simultaneously. The microcontroller programmed here contains a dual-channel asynchronous serial port that is comprised of two distinct universal asynchronous receiver-transmitters (UARTs). Although this application might seem to be a perfect example where it is possible to merge the software drivers for these two on-board devices into a single class, it is a case where the merging of the two programs will essentially double the total code, and it will increase the complexity of the software driver considerably. It was decided that the natural integration of multiple devices into a single object-oriented interface would best be demonstrated with the on-board general-purpose timer described in Chapters 5 and 6.

Several timer functions are developed in Chapters 5 and 6. These timers are based on the timers in the general-purpose timer (GPT). The GPT contains both output compare operations and input capture functions. You will find development of components to make use of the output compare systems in Chapter 5. There are four output compare systems on board the chip. Object-oriented interfaces to these output compare systems are created in a single class. Mechanizations are provided to attach a delay object to any timer. When needed, multiple operations can be controlled by each timer through the use of a linked list of object-oriented drivers that are executed with each output compare interrupt. Input capture operations are used to measure time between events. An object-oriented interface to the several on-board input capture systems is completed, and applications to make precision time measurements are shown in Chapter 6.

Chapter 7 is a data manual. The test is on components, and most components that we encounter in hardware have an associated data sheet. Data sheets for all the components derived in this book have been collected together and placed in Chapter 7. Here you can find how to use each software component, its parameters, and the essential items needed to use the class as a super class for the derivation of another class. I suspect that this chapter will be a well-used chapter of the book.

In Appendix A you will find a very brief description of the Cosmic C compiler used to develop code for the M68HC16 series of components. Appendix B includes several important header files needed to compile code for this chip family.

A CD-ROM is included with this book for your convenience. The contents of the CD-ROM should be installed on your hard drive. A command like:
x: > install y:
where x: is the volume of your CD-ROM drive and y: is the volume of the destination drive. This install command will create three directories on your hard drive: programs, html, and Cosmic.

The directory Programs contains all the executable code contained in the book. It is organized by chapter to help you find what you need. The directory Cosmic contains a demonstration C compiler from Cosmic software. This fine product will compile all the code contained in this book. The directory HTML contains a complete copy of the book. You are about to use one of the fine developments that has come from the World Wide Web. The language used to generate Web pages is called html for Hypertext Markup Language. This language allows you to create data pages that are formatted by the language rather than by the author. Look into any of the *.htm files in this directory to see what HTML files look like.

To access an HTML file you must use a Web Browser such as Netscape or any of the other popular programs. Once you get the program running, you can bring up the text with a command like:
where is the path of your html files. From that point on, it is merely point and click to move through the book.

I would like to take this opportunity to extend my thanks to the Semiconductor Products Sector of Motorola, Inc. for their support in the production of this book. Neil Krohn, my manager, is always there with encouragement to try new business ideas. This, my second book, has been written with his support and blessing. I could not have completed it without his help. My associates Lou Pagnuccon and A. J. Pohlmeyer have provided me with many interesting discussions that have shaped the contents of this book. Finally, I would also like to thank Brian Wilkie, Corporate Vice President and General Manager of the Advanced Microcontroller Division.

Ted Van Sickle

From the Back Cover
Helps real-time embedded systems designers combine the development benefits of the widely-used C language and object-oriented techniques not normally associated with C.Introduces object-oriented programming to microcontroller programmers familiar with C. Shows how objects can be written in C, and developed into classes. Presents useful objects and classes for microcontroller programs, including a class that creates instances of an asynchronous serial port. Shows how to implement components to handle timer functions and input capture. Compiles data sheets for all components derived in the book.Programmers working with real-time embedded systems.



PLEASE READ: All comments must be approved before appearing in the thread; time and space constraints prevent all comments from appearing. We will only approve comments that are directly related to the article, use appropriate language and are not attacking the comments of others.

Message (please, no HTML tags. Web addresses will be hyperlinked):

Related Free eBooks

Related Tags

DIGG This story   Save To Google   Save To Windows Live   Save To Del.icio.us   diigo it   Save To blinklist
Save To Furl   Save To Yahoo! My Web 2.0   Save To Blogmarks   Save To Shadows   Save To stumbleupon   Save To Reddit