Infinite_Maelstrom
Infinite_Maelstrom

Reputation: 169

How to find a specific AVR header file

I am rewriting some old code for an ATmega32M1. I would like to reuse some of this old code. In one place, the previous author has written:

Hard_reset();       // wait for watchdog to timeout

This Hard_reset(); is a macro defined in another file, and does exactly what the comment says: enable the watchdog and then enter an infinite loop. This included file is atmegaxxm1c1_drv.h, and its comments make it look like it is an official Atmel library header written in 2009 by a fellow named jtellier.

So far, no problems. But this file has been included separately, with an #include "atmegaxxm1c1_drv.h" referencing a version of this file that has been copied into the project's master directory. I'm not a huge expert in these matters, but this looks to me like a device-specific header that should be included under another, generic file; like how I don't need to include <avr/iom32m1.h> because <avr/io.h> includes it for me.

The problem is, I can't find what that header file is! I have searched through all the files on my PC, and the only time that file shows up is in this project - I would have expected it to also be included with the other AVR header files. I have searched for it on the interwebs, and Google manages to find one (1) single result - a download from some questionable-looking Chinese website (which, knowing who wrote this code, is probably where it came from initially... 😒).

My question is: Where does this file come from? How is this file supposed to be included?


Edit:

StackOverflow does not allow attaching files to questions, but I thought it would be helpful to post the introductory comment from the file. All other documentation within the file is about how the functions within it should be used.

//******************************************************************************
//! @file $RCSfile: atmegaxxm1c1_drv.h,v $
//!
//! Copyright (c) 2009 Atmel.
//!
//! Use of this program is subject to Atmel's End User License Agreement.
//! Please read file license.txt for copyright notice.
//!
//! @brief This file gives reference information about the intrinsic
//!        functions of AT9megaxxM1/C1 devices. These functions provide direct
//!        access to low-level processor operations.
//!
//! This file has been validated with:
//!     - AVRStudio 4.15.623,
//!     - IAR C/C++ Compiler for AVR 5.20.1 (5.20.1.50092)
//!
//! @version $Revision: 3.00 $ $Name: jtellier $
//!
//! @todo
//! @bug
//******************************************************************************

Upvotes: 0

Views: 592

Answers (1)

emacs drives me nuts
emacs drives me nuts

Reputation: 3993

My question is: How is this file supposed to be included?

Read the documentation in that file, or the documentation of the file including it.

  • There is no file named atmegaxxm1c1_drv.h in AVR-LibC, neither amongst the official interface, nor amongst the headers used internally in AVR-LibC.

  • There is no file named atmegaxxm1c1_drv.h in avr-gcc nor in libgcc for AVR.

So the only information we have is the file name.

a device-specific header that should be included under another, generic file like <avr/io.h>.

No. That file is not part of AVR-LibC. While you can hack anything into your local copy of AVR-LibC, nobody would do that.

Technically, there are three ways to include a file:

  1. #include "file.h" for ordinary headers.

  2. #include <file.h> for system headers.

  3. By means of gcc command line option -include file.h.

where the search path can be extended by means of -I path for a path containing ordinary headers, and by means of -isystem path for a path containing system headers.

Upvotes: 0

Related Questions