Chapter 1 Concepts for Developing Portable Firmware .3 Why Code Reuse Matters.3 Portable Firmware .5 Modularity . 11 Module Coupling and Cohesion. 12 Following A Standard . 14 Portability Issues in C - Data Types . 15 Portability Issues in C - Structures and Unions.
17 Portability Issues in C - Bit Fields. 18 Portability Issues in C - Preprocessor Directives . 19 Hardware Abstraction Layers (HAL) . 21 Application Programming Interfaces (APIs) . 28 Project Organization. 28 Getting Started Writing Portable Firmware . 29 Going Further . 32 Chapter 2 API and HAL Fundamentals.
37 The Wonderful World of HALs . 37 APIs versus HALs. 38 The API and HAL Landscape . 40 The Good, Bad and Ugly. 42 Potential Issues and the Boogeyman. 42 Characteristics Every HAL should Exhibit . 46 To Build or Not to Build. 56 A First Look at a HAL.
58 The API Scope . 59 API Characteristics to look for . 60 Designing your own APIs . 65 A First Look at an API . 65 Going Further . 67 Confidential - ©2016 Jacob Beningo, All Rights Reserved, DRAFT A08 Chapter 3 Device Driver Fundamentals in C.73 Understanding the Memory Map.73 Identifying Driver Interfaces.
77 Design by Contract.80 Assertion Fundamentals.83 Device Driver Models .85 Polled versus Interrupt Driven Drivers .87 Deciphering the volatile, const and static keywords .93 Driver Module Definition.93 Naming Convention Recommendations.95 Object Oriented Programming in C.
96 Encapsulation and Data Hiding .105 Abstract Data Types.105 Callback Functions .105 Error Handling.110 Expected Results and Recommendations.113 Leverage Design Patterns.114 Going Further .114 Chapter 4 Writing Reusable Drivers .
119 It''s All about the Interface.119 How much Abstraction is too much? .120 Wrapping the Interface .120 Memory Mapping Methodologies .128 Mapping Memory Directly.129 Mapping Memory with Pointers.130 Mapping Memory with Structures.133 Using Pointer Arrays in Driver Design .
136 Creating a Timer Driver Overview.138 Step #1 - Define the Timers Configuration Table .138 Step #2 - Define the Timers Peripheral Channels.140 Step #3 - Populate the Timers Configuration Table.141 Step #4 - Create the Timer Pointer Arrays .143 Step #5 - Create the Initialization Function .145 Step #6 - Fill in the Timer Driver Interface .150 Step #7 - Maintain and Port the Design Pattern.
150 Selecting the Right Driver Implementation.151 Going Further .152 Chapter 5 Documenting Firmware with Doxygen.157 The Importance of Good Documentation .157 Easing the Documentation Load .159 An Introduction to Doxygen .162 Confidential - ©2016 Jacob Beningo, All Rights Reserved, DRAFT A08 Installing Doxygen.164 Documentation Project Setup .
166 Doxygen Comment Fundamentals.173 Documenting enum and struct.174 Documenting Functions.175 Documenting Modules .181 Creating a Reusable Template .183 Generating a Main Page .184 10 Tips for Commenting C Code.187 Tip #1- Explain the Why not the How .
188 Tip #2 - Comment Before Coding.189 Tip #3 - Use Doxygen Tags.189 Tip #4 - Adopt a Code Style Guide .190 Tip #5 - Use a File Header .190 Tip #6 - Create a Commenting Template.191 Tip #7 - Consistent Comment Location.191 Tip #8 - Don''t Comment Every Line .192 Tip #9 - Start Mathematical type Identifiers with the Type.
193 Tip #10 - Update Comments with Code Updates .193 A Few Final Thoughts on Documentation.194 Going Further .