1 |
580 |
jeremybenn |
/* ----------------------------------------------------------------------------
|
2 |
|
|
* ATMEL Microcontroller Software Support
|
3 |
|
|
* ----------------------------------------------------------------------------
|
4 |
|
|
* Copyright (c) 2009, Atmel Corporation
|
5 |
|
|
*
|
6 |
|
|
* All rights reserved.
|
7 |
|
|
*
|
8 |
|
|
* Redistribution and use in source and binary forms, with or without
|
9 |
|
|
* modification, are permitted provided that the following conditions are met:
|
10 |
|
|
*
|
11 |
|
|
* - Redistributions of source code must retain the above copyright notice,
|
12 |
|
|
* this list of conditions and the disclaimer below.
|
13 |
|
|
*
|
14 |
|
|
* Atmel's name may not be used to endorse or promote products derived from
|
15 |
|
|
* this software without specific prior written permission.
|
16 |
|
|
*
|
17 |
|
|
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
18 |
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
19 |
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
20 |
|
|
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
21 |
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 |
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
23 |
|
|
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24 |
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25 |
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
26 |
|
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27 |
|
|
* ----------------------------------------------------------------------------
|
28 |
|
|
*/
|
29 |
|
|
//------------------------------------------------------------------------------
|
30 |
|
|
/// \unit
|
31 |
|
|
///
|
32 |
|
|
/// !Purpose
|
33 |
|
|
///
|
34 |
|
|
/// Interface for configuration the Enhanced Embedded Flash Controller (EEFC)
|
35 |
|
|
/// peripheral.
|
36 |
|
|
///
|
37 |
|
|
/// !Usage
|
38 |
|
|
///
|
39 |
|
|
/// -# Enable/disable %flash ready interrupt sources using EFC_EnableFrdyIt()
|
40 |
|
|
/// and EFC_DisableFrdyIt().
|
41 |
|
|
/// -# Translates the given address into which EEFC, page and offset values
|
42 |
|
|
/// for difference density %flash memory using EFC_TranslateAddress().
|
43 |
|
|
/// -# Computes the address of a %flash access given the EFC, page and offset
|
44 |
|
|
/// for difference density %flash memory using EFC_ComputeAddress().
|
45 |
|
|
/// -# Start the executing command with EFC_StartCommand()
|
46 |
|
|
/// -# Retrieve the current status of the EFC using EFC_GetStatus().
|
47 |
|
|
/// -# Retrieve the result of the last executed command with EFC_GetResult().
|
48 |
|
|
//------------------------------------------------------------------------------
|
49 |
|
|
#ifndef EEFC_H
|
50 |
|
|
#define EEFC_H
|
51 |
|
|
|
52 |
|
|
//------------------------------------------------------------------------------
|
53 |
|
|
// Headers
|
54 |
|
|
//------------------------------------------------------------------------------
|
55 |
|
|
|
56 |
|
|
#include <board.h>
|
57 |
|
|
|
58 |
|
|
#if !defined (CHIP_FLASH_EEFC)
|
59 |
|
|
#error eefc not supported
|
60 |
|
|
#endif
|
61 |
|
|
|
62 |
|
|
//------------------------------------------------------------------------------
|
63 |
|
|
// Constants
|
64 |
|
|
//------------------------------------------------------------------------------
|
65 |
|
|
|
66 |
|
|
//------------------------------------------------------------------------------
|
67 |
|
|
// Types
|
68 |
|
|
//------------------------------------------------------------------------------
|
69 |
|
|
|
70 |
|
|
// Needed when EEFC is integrated in MC.
|
71 |
|
|
#if !defined(AT91C_BASE_EFC) && defined(AT91C_BASE_MC)
|
72 |
|
|
typedef struct _AT91S_EFC {
|
73 |
|
|
AT91_REG EFC_FMR; // EFC Flash Mode Register
|
74 |
|
|
AT91_REG EFC_FCR; // EFC Flash Command Register
|
75 |
|
|
AT91_REG EFC_FSR; // EFC Flash Status Register
|
76 |
|
|
AT91_REG EFC_FRR; // EFC Flash Result Register
|
77 |
|
|
AT91_REG EFC_FVR; // EFC Flash Version Register
|
78 |
|
|
} AT91S_EFC, *AT91PS_EFC;
|
79 |
|
|
|
80 |
|
|
#define AT91C_EFC_FRDY AT91C_MC_FRDY
|
81 |
|
|
#define AT91C_EFC_FWS AT91C_MC_FWS
|
82 |
|
|
#define AT91C_EFC_FWS_0WS AT91C_MC_FWS_0WS
|
83 |
|
|
#define AT91C_EFC_FWS_1WS AT91C_MC_FWS_1WS
|
84 |
|
|
#define AT91C_EFC_FWS_2WS AT91C_MC_FWS_2WS
|
85 |
|
|
#define AT91C_EFC_FWS_3WS AT91C_MC_FWS_3WS
|
86 |
|
|
#define AT91C_EFC_FCMD AT91C_MC_FCMD
|
87 |
|
|
#define AT91C_EFC_FCMD_GETD AT91C_MC_FCMD_GETD
|
88 |
|
|
#define AT91C_EFC_FCMD_WP AT91C_MC_FCMD_WP
|
89 |
|
|
#define AT91C_EFC_FCMD_WPL AT91C_MC_FCMD_WPL
|
90 |
|
|
#define AT91C_EFC_FCMD_EWP AT91C_MC_FCMD_EWP
|
91 |
|
|
#define AT91C_EFC_FCMD_EWPL AT91C_MC_FCMD_EWPL
|
92 |
|
|
#define AT91C_EFC_FCMD_EA AT91C_MC_FCMD_EA
|
93 |
|
|
#define AT91C_EFC_FCMD_EPL AT91C_MC_FCMD_EPL
|
94 |
|
|
#define AT91C_EFC_FCMD_EPA AT91C_MC_FCMD_EPA
|
95 |
|
|
#define AT91C_EFC_FCMD_SLB AT91C_MC_FCMD_SLB
|
96 |
|
|
#define AT91C_EFC_FCMD_CLB AT91C_MC_FCMD_CLB
|
97 |
|
|
#define AT91C_EFC_FCMD_GLB AT91C_MC_FCMD_GLB
|
98 |
|
|
#define AT91C_EFC_FCMD_SFB AT91C_MC_FCMD_SFB
|
99 |
|
|
#define AT91C_EFC_FCMD_CFB AT91C_MC_FCMD_CFB
|
100 |
|
|
#define AT91C_EFC_FCMD_GFB AT91C_MC_FCMD_GFB
|
101 |
|
|
#define AT91C_EFC_FARG AT91C_MC_FARG
|
102 |
|
|
#define AT91C_EFC_FKEY AT91C_MC_FKEY
|
103 |
|
|
#define AT91C_EFC_FRDY_S AT91C_MC_FRDY_S
|
104 |
|
|
#define AT91C_EFC_FCMDE AT91C_MC_FCMDE
|
105 |
|
|
#define AT91C_EFC_LOCKE AT91C_MC_LOCKE
|
106 |
|
|
#define AT91C_EFC_FVALUE AT91C_MC_FVALUE
|
107 |
|
|
|
108 |
|
|
#define AT91C_BASE_EFC (AT91_CAST(AT91PS_EFC) 0xFFFFFF60)
|
109 |
|
|
|
110 |
|
|
#endif //#if !defined(AT91C_BASE_EFC) && defined(AT91C_BASE_MC)
|
111 |
|
|
|
112 |
|
|
//------------------------------------------------------------------------------
|
113 |
|
|
// Functions
|
114 |
|
|
//------------------------------------------------------------------------------
|
115 |
|
|
|
116 |
|
|
extern void EFC_EnableFrdyIt(AT91S_EFC *pEfc);
|
117 |
|
|
|
118 |
|
|
extern void EFC_DisableFrdyIt(AT91S_EFC *pEfc);
|
119 |
|
|
|
120 |
|
|
extern void EFC_TranslateAddress(
|
121 |
|
|
AT91S_EFC **ppEfc,
|
122 |
|
|
unsigned int address,
|
123 |
|
|
unsigned short *pPage,
|
124 |
|
|
unsigned short *pOffset);
|
125 |
|
|
|
126 |
|
|
extern void EFC_ComputeAddress(
|
127 |
|
|
AT91S_EFC *pEfc,
|
128 |
|
|
unsigned short page,
|
129 |
|
|
unsigned short offset,
|
130 |
|
|
unsigned int *pAddress);
|
131 |
|
|
|
132 |
|
|
extern void EFC_StartCommand(
|
133 |
|
|
AT91S_EFC *pEfc,
|
134 |
|
|
unsigned char command,
|
135 |
|
|
unsigned short argument);
|
136 |
|
|
|
137 |
|
|
extern unsigned char EFC_PerformCommand(
|
138 |
|
|
AT91S_EFC *pEfc,
|
139 |
|
|
unsigned char command,
|
140 |
|
|
unsigned short argument);
|
141 |
|
|
|
142 |
|
|
extern unsigned int EFC_GetStatus(AT91S_EFC *pEfc);
|
143 |
|
|
|
144 |
|
|
extern unsigned int EFC_GetResult(AT91S_EFC *pEfc);
|
145 |
|
|
|
146 |
|
|
#endif //#ifndef EEFC_H
|
147 |
|
|
|