Skip to Content
The Microprocessor
book

The Microprocessor

by Darshak S. Vasavada, S. K. Sinha
July 2025
Beginner
528 pages
13h 18m
English
Wiley
Content preview from The Microprocessor

APPENDIX DAM0 Header Files

This chapter contains two header files for the abstract microcontroller AM0 used in chapters 17 to 19: am0_regs.h, which defines the memory-mapped peripheral registers, and am0.h, which defines application programming interface (API) for accessing the peripherals.

D.1 REGISTER HEADER FILE

A microcontroller vendor typically provides a platform header file that contains definitions of all the memory-mapped registers. Since we have defined the AM0 peripherals, let us create its header file am0_regs.h.

Quite often, a header file also includes definitions of individual bits and their positions within a register. We will omit these from am0_regs.h for simplicity.

#ifndef AM0_REGS_H
#define AM0_REGS_H
 
 
#define IOREG(addr) (*(volatile long *)(addr))
 
 
#define GPIO_DAT  IOREG(0x40001000)  // GPIO data register
#define GPIO_DIR  IOREG(0x40001004)  // GPIO direction register
#define GPIO_INT  IOREG(0x40001008)  // GPIO interrupt enable register
 
 
#define TIMER_CSR IOREG(0x40002000)  // Timer control and status register
#define TIMER_RVR IOREG(0x40002004)  // Timer reload value register
#define TIMER_CVR IOREG(0x40002008)  // Timer current value register
 
 
#define ADC_DAT   IOREG(0x40003000)  // ADC data register
 
 
#define DAC_DAT   IOREG(0x40004000)  // DAC data register
 
 
#define UART_CSR  IOREG(0x40005000)  // UART control and status register
#define UART_RDR  IOREG(0x40005004)  // UART receive data register
#define UART_TDR  IOREG(0x40005008)  // UART transmit data register
 
 
#define ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Computer Architecture

Computer Architecture

Charles Fox

Publisher Resources

ISBN: 9781394245291