Download presentation
Presentation is loading. Please wait.
1
Baremetal C Programming for Embedded Systems
Class 5: Writing Portable Code February 27, 2015 Jacob Beningo, CSDP
2
Course Overview C Concepts for Embedded Systems
Baremetal Scheduling Techniques Driver Design Techniques Design Patterns for Firmware Writing Portable Code
3
Session Overview Why Write Portable Code? API Design An EEPROM Example
4
Benefits of Portable Code
Easily moved from one MCU to the next Proven and tested Decreases development time Decreases costs Familiarity which makes maintenance easier
5
Hardware Abstraction Layer
6
API’s 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 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
7
API’s Digital Input / Output (Gpio) Serial Peripheral Interface EEPROM
8
EEPROM Overview
9
EEPROM Configuration Header Definitions
10
EEPROM Configuration Source Definitions
11
EEPROM Driver Header Definitions
12
EEPROM Driver Initialization
13
EEPROM Driver Write Status Register
14
EEPROM Driver Read Status Register
15
Portable Code Tips Avoid the use of #pragma
Keep modules as de-coupled as possible One “function” per module Create an API Keep configuration separate from implementation Use only standard C concepts (bit field ex.) Encapsulation and data hiding
16
Course Review Use of static and volatile A Review of C Concepts
Scheduling Techniques Methods of Accessing Memory Circular Buffers Driver Design GPIO, SPI, External EEPROM
17
Additional Resources Download Course Material for
Updated C Doxygen Templates (Feb 2015) Example drivers source code Microcontroller API Standard EDN Embedded Basics Articles Embedded Bytes Newsletter From under - Blog and Articles > Software Techniques > CEC Baremetal C Programming
18
Jacob Beningo Newsletters P.O. Box 400 Embedded Bytes
Linden, Michigan 48451 Newsletters Embedded Bytes Training MicroPython Bootloaders Low Power Design Real-time Software C/C++ Embedded : : : Jacob_Beningo : Beningo Engineering : JacobBeningo : Embedded Basics Jacob Beningo Principal Consultant 18
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.