Takumi Odashima / ArduinoUsbHostShield

Dependents:   USBHOST_PS5

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pgmspace.h Source File

pgmspace.h

00001 /*
00002   pgmspace.h - Definitions for compatibility with AVR pgmspace macros
00003 
00004   Copyright (c) 2015 Arduino LLC
00005 
00006   Based on work of Paul Stoffregen on Teensy 3 (http://pjrc.com)
00007 
00008   Permission is hereby granted, free of charge, to any person obtaining a copy
00009   of this software and associated documentation files (the "Software"), to deal
00010   in the Software without restriction, including without limitation the rights
00011   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00012   copies of the Software, and to permit persons to whom the Software is
00013   furnished to do so, subject to the following conditions:
00014 
00015   The above copyright notice and this permission notice shall be included in
00016   all copies or substantial portions of the Software.
00017 
00018   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00019   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00021   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00022   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00023   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00024   THE SOFTWARE
00025 */
00026 
00027 #ifndef __PGMSPACE_H_
00028 #define __PGMSPACE_H_ 1
00029 
00030 #include <inttypes.h>
00031 
00032 #define PROGMEM
00033 #define PGM_P  const char *
00034 #define PSTR(str) (str)
00035 
00036 #define _SFR_BYTE(n) (n)
00037 
00038 typedef void prog_void;
00039 typedef char prog_char;
00040 typedef unsigned char prog_uchar;
00041 typedef int8_t prog_int8_t;
00042 typedef uint8_t prog_uint8_t;
00043 typedef int16_t prog_int16_t;
00044 typedef uint16_t prog_uint16_t;
00045 typedef int32_t prog_int32_t;
00046 typedef uint32_t prog_uint32_t;
00047 
00048 #define memcpy_P(dest, src, num) memcpy((dest), (src), (num))
00049 #define strcpy_P(dest, src) strcpy((dest), (src))
00050 #define strcat_P(dest, src) strcat((dest), (src))
00051 #define strcmp_P(a, b) strcmp((a), (b))
00052 #define strstr_P(a, b) strstr((a), (b))
00053 #define strlen_P(a) strlen((a))
00054 #define sprintf_P(s, f, ...) sprintf((s), (f), __VA_ARGS__)
00055 
00056 #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
00057 #define pgm_read_word(addr) (*(const unsigned short *)(addr))
00058 #define pgm_read_dword(addr) (*(const unsigned long *)(addr))
00059 #define pgm_read_float(addr) (*(const float *)(addr))
00060 
00061 #define pgm_read_byte_near(addr) pgm_read_byte(addr)
00062 #define pgm_read_word_near(addr) pgm_read_word(addr)
00063 #define pgm_read_dword_near(addr) pgm_read_dword(addr)
00064 #define pgm_read_float_near(addr) pgm_read_float(addr)
00065 #define pgm_read_byte_far(addr) pgm_read_byte(addr)
00066 #define pgm_read_word_far(addr) pgm_read_word(addr)
00067 #define pgm_read_dword_far(addr) pgm_read_dword(addr)
00068 #define pgm_read_float_far(addr) pgm_read_float(addr)
00069 
00070 #endif
00071