pgm格式文件c语言怎么读取,求pgmspace.h文件下的pgm_read_byte函数?好像是WinAVR或GCC环境下的库文件...

/* Copyright (c) 2002 - 2007  Marek Michalkiewicz

All rights reserved.

Redistribution and use in source and binary forms, with or without

modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright

notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright

notice, this list of conditions and the following disclaimer in

the documentation and/or other materials provided with the

distribution.

* Neither the name of the copyright holders nor the names of

contributors may be used to endorse or promote products derived

from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

POSSIBILITY OF SUCH DAMAGE. */

/* $Id: pgmspace.h,v 1.40 2007/03/30 04:37:14 arcanum Exp $ */

/*

pgmspace.h

Contributors:

Created by Marek Michalkiewicz

Eric B. Weddington

Wolfgang Haidinger (pgm_read_dword())

*/

/** \file */

/** \defgroup avr_pgmspace : Program Space Utilities

\code

#include

#include

\endcode

The functions in this module provide interfaces for a program to access

data stored in program space (flash memory) of the device.  In order to

use these functions, the target device must support either the \c LPM or

\c ELPM instructions.

\note These functions are an attempt to provide some compatibility with

header files that come with IAR C, to make porting applications between

different compilers easier.  This is not 100% compatibility though (GCC

does not have full support for multiple address spaces yet).

\note If you are working with strings which are completely based in ram,

use the standard string functions described in \ref avr_string.

\note If possible, put your constant tables in the lower 64 KB and use

pgm_read_byte_near() or pgm_read_word_near() instead of

pgm_read_byte_far() or pgm_read_word_far() since it is more efficient that

way, and you can still use the upper 64K for executable code.

All functions that are suffixed with a \c _P \e require their

arguments to be in the lower 64 KB of the flash ROM, as they do

not use ELPM instructions.  This is normally not a big concern as

the linker setup arranges any program space constants declared

using the macros from this header file so they are placed right after

the interrupt vectors, and in front of any executable code.  However,

it can become a problem if there are too many of these constants, or

for bootloaders on devices with more than 64 KB of ROM.

All these functions will not work in that situation.

*/

#ifndef __PGMSPACE_H_

#define __PGMSPACE_H_ 1

#define __need_size_t

#include

#include

#include

#ifndef __ATTR_CONST__

#define __ATTR_CONST__ __attribute__((__const__))

#endif

#ifndef __ATTR_PROGMEM__

#define __ATTR_PROGMEM__ __attribute__((__progmem__))

#endif

#ifndef __ATTR_PURE__

#define __ATTR_PURE__ __attribute__((__pure__))

#endif

/**

\ingroup avr_pgmspace

\def PROGMEM

Attribute to use in order to declare an object being located in

flash ROM.

*/

#define PROGMEM __ATTR_PROGMEM__

#ifdef __cplusplus

extern "C" {

#endif

#if defined(__DOXYGEN__)

/*

* Doxygen doesn't grok the appended attribute syntax of

* GCC, and confuses the typedefs with function decls, so

* supply a doxygen-friendly view.

*/

/**

\ingroup avr_pgmspace

\typedef prog_void

Type of a "void" object located in flash ROM.  Does not make much

sense by itself, but can be used to declare a "void *" object in

flash ROM.

*/

typedef void PROGMEM prog_void;

/**

\ingroup avr_pgmspace

\typedef prog_char

Type of a "char" object located in flash ROM.

*/

typedef char PROGMEM prog_char;

/**

\ingroup avr_pgmspace

\typedef prog_uchar

Type of an "unsi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值