1 / 19

Fundamentals of Embedded Software Design

Fundamentals of Embedded Software Design. Day 4: Organizing and Developing Reusable Code. November 21, 2013 Jacob Beningo, CSDP. Course Overview. Introduction to Embedded Systems Developing a Software Architecture A Review of C Programming Techniques Organizing and Developing Reusable Code

rlucille
Download Presentation

Fundamentals of Embedded Software Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fundamentals of Embedded Software Design Day 4: Organizing and Developing Reusable Code November 21, 2013Jacob Beningo, CSDP

  2. Course Overview • Introduction to Embedded Systems • Developing a Software Architecture • A Review of C Programming Techniques • Organizing and Developing Reusable Code • Writing a Memory Mapped Driver for a Timer

  3. Session Overview • Software Design Goals • Software Architecture Goals • Application Protocol Interface (API’s) • Modularity and Code Organization • Code Coupling • Object Oriented Design Techniques • The end result

  4. Software Design Goals • The software design cycle problem • Tight/shrinking budgets • Shortened development cycles • Feature creep • Intense competition • Software bugs • Customer feature expectations • What can be done to speed up the development cycle? • How much time is spent developing and validating drivers?

  5. Software Design Goals • Write software that is reusable! • This can be done through • Designing and using a layered software architecture. • Defining and using API’s • Modularity • Decreasing module coupling • Following object oriented design techniques

  6. Software Architecture Goals • Many different ways to organize code • Break the code up into different layers (but keep it simple!) • Driver Layer • Contains MCU peripheral drivers • Generic initialization functions • MCU start-up and copy down • Might contain board support package drivers for external chips

  7. Software Architecture Goals • Application Layer • Product features • Scheduler • Applications for drivers • Ex. External EEPROM configuration application • Ex. Button response behavior • Configuration Layer • Configuration for drivers • Configuration for applications • Application settings

  8. Application Protocol Interface Application Programming Interfaces • Critical to creating reusable software • Defines a common interface that can be used from one project to the next • Identifies useful peripheral features (think driver and application layer) • If adhered to at a driver level application code can be reused and ported with ease Example API’s and Standards • Linux Kernel • AUTOSAR • Arduino Libraries • Custom • etc

  9. Application Protocol Interface Digital Input / Output API’s Serial Peripheral Interface EEPROM

  10. Modularity and Code Organization • Characteristics of Modular Code • Header and Source files are dedicated to a specific function • Digital I/O • SPI Communication • Sensor Interfacing • Etc • Modules can be interchangeable • Swap a Microchip Spi Driver for a Freescale Spi Driver • Use ANSI standard coding techniques • Not all language features are supported by all compilers so use standard techniques! • Separates interface (.h) from the implementation (.c) • Easier to design and maintain • Breaks the problem up into smaller manageable pieces

  11. Modularity and Code Organization • Examples Main Application Main Application EEPROM Application EEPROM Application EEPROM Driver Freescale Part EEPROM Driver Microchip Part

  12. Modularity and Code Organization • How to decide what functions go together? • Software architecture diagrams will naturally hint at modules • Decompose the layers in the architecture • Decompose those layers into independent features and functionality

  13. Modularity and Code Organization • What effects how the source code is organized? • Compiler • Forces a separation of header and source files? • Allow creation of folders and subfolders? • Architecture Decisions • Application • Hardware

  14. Modularity and Code Organization • How should the code be organized? • Separate header and source files • Separate the individual layers • Drivers • Application • Task Schedulers • Protocol Stacks • Configuration • Supporting Files and docs • It should be easy to find a module! • File system organization should match! • Allows for layers to be easily swapped

  15. Module Coupling • What is module coupling and why do we care? Main.c EEPROM_App.c Sensor.c Filter.c EEPROM.c Dio.c SPI.c

  16. Module Coupling • Examples Main Application Main Application EEPROM Application Flash Application EEPROM Application EEPROM Driver Flash Driver EEPROM Driver

  17. Object Oriented Design • Modules should look like black boxes • Exposed interfaces • Implementation hidden • Data hiding • Variables local to the module • LIMITED USE OF GLOBAL VARIABLES • Limited dependencies on other modules • Use interface to set and read variables

  18. The End Result • Modular Software is simpler • Easier to test • Easier to debug • Ease of configuration • Loosely coupled allowing a change in one module to minimally affect other modules • Can be reused in future projects, thus saving • Future development costs • Time to market

  19. Questions Contact Info Jacob Beningo jacob@beningo.com www.beningo.com Jacob_Beningo Beningo Engineering JacobBeningo Embedded Basics

More Related