Programming Embedded Systems by Michael Barr & Anthony Massa
Author:Michael Barr & Anthony Massa [Michael Barr]
Language: eng
Format: epub
Tags: COMPUTERS / Hardware / General
ISBN: 9780596553289
Publisher: O'Reilly Media
Published: 2009-02-08T16:00:00+00:00
Struct Overlays
In embedded systems featuring memory-mapped I/O devices, it is sometimes useful to overlay a C struct onto each peripheralâs control and status registers. Benefits of struct overlays are that you can read and write through a pointer to the struct, the register is described nicely by the struct, code can be kept clean, and the compiler does the address construction at compile time.
The following example code shows a struct overlay for a timer peripheral. If a peripheralâs registers do not align correctly, reserved members can be included in the struct. Thus, in the following example, an extra field that youâll never refer to is included at offset 4 so that the control field lies properly at offset 6.
typedef struct { uint16_t count; /* Offset 0 */ uint16_t maxCount; /* Offset 2 */ uint16_t _reserved1; /* Offset 4 */ uint16_t control; /* Offset 6 */ } volatile timer_t; timer_t *pTimer = (timer_t *)(0xABCD0123);
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Computer Design | Control Systems |
DSPs | Embedded Systems |
Microprocessor Design | PIC Microcontroller |
Linux Device Driver Development Cookbook by Rodolfo Giometti(3932)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3596)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3535)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3361)
TinyML Cookbook by Gian Marco Iodice(3301)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2839)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2601)
Fusion 360 for Makers by Lydia Sloan Cline(2219)
Networking A Beginner's Guide by Bruce Hallberg(2209)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2030)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1951)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1947)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1899)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1860)
MicroPython Projects by Jacob Beningo(1731)
Hands-On Internet of Things with MQTT by Tim Pulver(1706)
