Trailing whitespace
[bertos.git] / bertos / cpu / cortex-m3 / io / sam3_flash.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \brief Atmel SAM3 enhanced embedded flash controller definitions.
34  */
35
36 #ifndef SAM3_FLASH_H
37 #define SAM3_FLASH_H
38
39 /**
40  * EEFC base registers addresses.
41  */
42 /*\{*/
43 #define EEFC0_BASE  0x400E0A00
44 #ifdef CPU_CM3_SAM3X
45         #define EEFC1_BASE  0x400E0C00
46 #endif
47 /*\}*/
48
49
50 /**
51  * EFC register offsets.
52  */
53 /*\{*/
54 #define EEFC_FMR_OFF  0x0   ///< Flash Mode Register
55 #define EEFC_FCR_OFF  0x4   ///< Flash Command Register
56 #define EEFC_FSR_OFF  0x8   ///< Flash Status Register
57 #define EEFC_FRR_OFF  0xC   ///< Flash Result Register
58 /*\}*/
59
60 /**
61  * EEFC registers.
62  */
63 /*\{*/
64 #define EEFC0_FMR  (*((reg32_t *)(EEFC0_BASE + EEFC_FMR_OFF)))  ///< Flash Mode Register
65 #define EEFC0_FCR  (*((reg32_t *)(EEFC0_BASE + EEFC_FCR_OFF)))  ///< Flash Command Register
66 #define EEFC0_FSR  (*((reg32_t *)(EEFC0_BASE + EEFC_FSR_OFF)))  ///< Flash Status Register
67 #define EEFC0_FRR  (*((reg32_t *)(EEFC0_BASE + EEFC_FRR_OFF)))  ///< Flash Result Register
68
69 #ifdef CPU_CM3_SAM3X
70         #define EEFC1_FMR  (*((reg32_t *)(EEFC1_BASE + EEFC_FMR_OFF)))  ///< Flash Mode Register
71         #define EEFC1_FCR  (*((reg32_t *)(EEFC1_BASE + EEFC_FCR_OFF)))  ///< Flash Command Register
72         #define EEFC1_FSR  (*((reg32_t *)(EEFC1_BASE + EEFC_FSR_OFF)))  ///< Flash Status Register
73         #define EEFC1_FRR  (*((reg32_t *)(EEFC1_BASE + EEFC_FRR_OFF)))  ///< Flash Result Register
74 #endif
75 /*\}*/
76
77
78
79 /**
80  * Defines for bit fields in EEFC_FMR register.
81  */
82 /*\{*/
83 #define EEFC_FMR_FRDY        0                       ///< Ready Interrupt Enable
84 #define EEFC_FMR_FWS_SHIFT   8
85 #define EEFC_FMR_FWS_MASK    (0xf << EEFC_FMR_FWS_SHIFT) ///< Flash Wait State
86 #define EEFC_FMR_FWS(value)  (EEFC_FMR_FWS_MASK & ((value) << EEFC_FMR_FWS_SHIFT))
87 #define EEFC_FMR_FAM         24                      ///< Flash Access Mode
88 /*\}*/
89
90 /**
91  * Defines for bit fields in EEFC_FCR register.
92  */
93 /*\{*/
94 #define EFC_FCR_FCMD_MASK     0x000000FF      ///< Flash command mask.
95 #define EFC_FCR_FCMD_GETD     0x00000000      ///< Get flash Descriptor.
96 #define EFC_FCR_FCMD_WP       0x00000001      ///< Write page.
97 #define EFC_FCR_FCMD_WPL      0x00000002      ///< Write page and lock.
98 #define EFC_FCR_FCMD_EWP      0x00000003      ///< Erase page and write page.
99 #define EFC_FCR_FCMD_EWPL     0x00000004      ///< Erase page and write page then lock.
100 #define EFC_FCR_FCMD_EA       0x00000005      ///< Erase all.
101 #define EFC_FCR_FCMD_SLB      0x00000008      ///< Set lock bit.
102 #define EFC_FCR_FCMD_CLB      0x00000009      ///< Clear lock bit.
103 #define EFC_FCR_FCMD_GLB      0x0000000A      ///< Get lock bit.
104 #define EFC_FCR_FCMD_SGPB     0x0000000B      ///< Set GPNVM bit.
105 #define EFC_FCR_FCMD_CGPB     0x0000000C      ///< Clear GPNVM bit.
106 #define EFC_FCR_FCMD_GGPB     0x0000000D      ///< Get GPNVM bit.
107 #define EFC_FCR_FCMD_STUI     0x0000000E      ///< Start read uniqune identifier.
108 #define EFC_FCR_FCMD_SPUI     0x0000000F      ///< Stop read uniqune identifier.
109 #define EFC_FCR_FCMD_GCALB    0x00000010      ///< Get CALIB bit.
110 #define EEFC_FCR_FARG_SHIFT   8
111 #define EEFC_FCR_FARG_MASK    (0xffff << EEFC_FCR_FARG_SHIFT) ///< Flash Command Argument
112 #define EEFC_FCR_FARG(value)  (EEFC_FCR_FARG_MASK & ((value) << EEFC_FCR_FARG_SHIFT))
113 #define EEFC_FCR_FKEY          0x5A000000      ///< Writing protect key.
114 /*\}*/
115
116 /**
117  * Defines for bit fields in EEFC_FSR register.
118  */
119 /*\{*/
120 #define EEFC_FSR_FRDY       0  ///< Flash Ready Status
121 #define EEFC_FSR_FCMDE      1  ///< Flash Command Error Status
122 #define EEFC_FSR_FLOCKE     2  ///< Flash Lock Error Status
123 /*\}*/
124
125 #endif /* SAM3_FLASH_H */