1 / 9

Representing and Manipulating Hardware in Standard C and C++

Representing and Manipulating Hardware in Standard C and C++. by Dan Saks. Overview. This presentation was about hardware manipulation using ANSI C and ANSI C++ common idioms for controlling devices make code more portable. Aids for Embedded Programming. Features provided by C and C++

Télécharger la présentation

Representing and Manipulating Hardware in Standard C and C++

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. Representing and Manipulating Hardware in Standard C and C++ by Dan Saks

  2. Overview • This presentation was about • hardware manipulation using ANSI C and ANSI C++ • common idioms for controlling devices • make code more portable

  3. Aids for Embedded Programming • Features provided by C and C++ • bitwise operators and bitfields • const qualifier • volatile qualifier • type sig_atomic_t • Feature provided by C++ • Class concept (encapsulation of hardware)

  4. I/O Architectures • Presentation was especially about memory mapped i/o architectures (ex. Motorola) • C and C++ are best at MMIO • Port I/O was tackled at the end

  5. Basic Techniques • How to represent a register • use the correspondent type (eg. one byte => char) • How to assign an adres to a variable in C/C++ • not possible • solution: declare a pointer with the specified adres • How to change bits in a register • use masks • Use structs when registers are physically colocated

  6. Compiler optimizations • Several compiler optimizations are based on variables • distinction `standard` variable and `device` variable is not made by compiler • compiler could alter program making it incorrect • use the keyword `volatile` • for a volatile variable the compiler will not make optimizitions

  7. More Advanced Topics • Access the register on a per bit base • use a struct • often big/little endian problems • Classes • public functions are used to read/write values • overhead can be eliminated thanks to inlining • the object encapsulates exact position/structure of register • Write-only registers

  8. More Advanced Topics • Port I/O • no standard C or C++ solution • rely on ASM or language extensions • Interrupt Handling • als no standard C or C++ solution • rely on ASM or language extensions • sig_atomic_t: use it in asynchronous environments (as environments where interrupts occur)

  9. Conclusion • Tutorial was ... • interesting for C/C++ programmers • not groundbreaking in terms of new concepts • interesting part (use of classes) not seen in depth

More Related