AVR-LibC  2.3.0git
Standard C library for AVR-GCC
 

AVR-LibC Documen­tation

AVR-LibC Development Pages

Main Page

User Manual

Library Refe­rence

FAQ

Example Projects

File List

Index

Loading...
Searching...
No Matches
eedef.h
1/* Copyright (c) 2009 Dmitry Xmelkov
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13 * Neither the name of the copyright holders nor the names of
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE. */
28
29#ifndef _EEDEF_H_
30#define _EEDEF_H_ 1
31
32#ifndef __DOXYGEN__
33
34#include <bits/devinfo.h>
35
36/* EEPROM address arg for a set of byte/word/dword functions and for
37 the internal eeprom_read_blraw(). */
38#define addr_lo r24
39#define addr_hi r25
40
41/* Number of bytes arg for all block read/write functions, include
42 internal. */
43#define n_lo r20
44#define n_hi r21
45
46#if __AVR_XMEGA__
47
48# define NVM_BASE NVM_ADDR0
49
50#if defined(NVMCTRL_CTRLA)
51# undef NVM_BASE
52# define NVM_BASE NVMCTRL_CTRLA
53
54# define NVM_ADDR0 NVMCTRL_ADDR0
55# define NVM_ADDR1 NVMCTRL_ADDR1
56# define NVM_DATA0 NVMCTRL_DATA0
57# define NVM_DATA1 NVMCTRL_DATA1
58# define NVM_NVMBUSY_bp NVMCTRL_EEBUSY_bp
59# define NVM_STATUS NVMCTRL_STATUS
60# define NVM_CTRLA NVMCTRL_CTRLA
61# define NVM_CTRLB NVMCTRL_CTRLB
62# ifndef CCP_SPM_gc
63# define CCP_SPM_gc (0x9D)
64# endif
65# ifndef NVMCTRL_CMD_PAGEERASEWRITE_gc
66# if NVMCTRL_CMD_gm == 0x7F
67# if defined (__AVR_Ex__)
68 /* AVR-Ex family
69 * value of NVMCTRL_CMD_enum.NVMCTRL_CMD_EEPERW_gc */
70# define NVMCTRL_CMD_PAGEERASEWRITE_gc (0x15<<0)
71# elif defined (__AVR_Dx__) || defined (__AVR_SD__)
72 /* AVR-Dx family
73 * value of NVMCTRL_CMD_enum.NVMCTRL_CMD_EEERWR_gc */
74# define NVMCTRL_CMD_PAGEERASEWRITE_gc (0x13<<0)
75# else
76 /* To support a new device, define NVMCTRL CMD_PAGEERASEWRITE_gc
77 * with the value of "Erase and Write EEPROM Page" comand code
78 * for - Persistent Memory Controller (NVMCTRL). */
79# error "Not supported devices"
80# endif
81# else
82 /* the rest of the AVR devices with NVMCTRL_CTRLA (0x07)
83 * value of NVMCTRL_CMD_enum.NVMCTRL_CMD_PAGEERASEWRITE_gc */
84# define NVMCTRL_CMD_PAGEERASEWRITE_gc 3
85# endif
86# endif /* NVMCTRL_CMD_PAGEERASEWRITE_gc */
87#endif /* defined(NVMCTRL_CTRLA) */
88#else
89
90# if !defined (EECR) && defined (DEECR) /* AT86RF401 */
91# define EECR DEECR
92# define EEARL DEEAR
93# define EEDR DEEDR
94# endif
95
96# if !defined (EERE) && defined (EER) /* AT86RF401 */
97# define EERE EER
98# endif
99
100# if !defined (EEWE) && defined (EEPE) /* A part of Mega and Tiny */
101# define EEWE EEPE
102# endif
103# if !defined (EEWE) && defined (EEL) /* AT86RF401 */
104# define EEWE EEL
105# endif
106
107# if !defined (EEMWE) && defined (EEMPE) /* A part of Mega and Tiny */
108# define EEMWE EEMPE
109# endif
110# if !defined (EEMWE) && defined (EEU) /* AT86RF401 */
111# define EEMWE EEU
112# endif
113
114# if !_SFR_IO_REG_P (EECR) \
115 || !_SFR_IO_REG_P (EEDR) \
116 || !_SFR_IO_REG_P (EEARL) \
117 || (defined (EEARH) && !_SFR_IO_REG_P (EEARH))
118# error
119# endif
120
121#endif /* !__AVR_XMEGA__ */
122#endif /* !__DOXYGEN__ */
123#endif /* !_EEDEF_H_ */