1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2012, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
35 * Interface for configuration the Enhanced Embedded Flash Controller (EEFC)
\r
40 * -# Enable/disable %flash ready interrupt sources using EFC_EnableFrdyIt()
\r
41 * and EFC_DisableFrdyIt().
\r
42 * -# Translates the given address into which EEFC, page and offset values
\r
43 * for difference density %flash memory using EFC_TranslateAddress().
\r
44 * -# Computes the address of a %flash access given the EFC, page and offset
\r
45 * for difference density %flash memory using EFC_ComputeAddress().
\r
46 * -# Start the executing command with EFC_PerformCommand()
\r
47 * -# Retrieve the current status of the EFC using EFC_GetStatus().
\r
48 * -# Retrieve the result of the last executed command with EFC_GetResult().
\r
54 /*----------------------------------------------------------------------------
\r
56 *----------------------------------------------------------------------------*/
\r
61 /*----------------------------------------------------------------------------
\r
63 *----------------------------------------------------------------------------*/
\r
64 /* TODO: Temporary definition for missing symbol in header file */
\r
65 #define IFLASH_SECTOR_SIZE 65536u
\r
69 #define EFC_FCMD_GETD 0x00 /* Get Flash Descriptor */
\r
70 #define EFC_FCMD_WP 0x01 /* Write page */
\r
71 #define EFC_FCMD_WPL 0x02 /* Write page and lock */
\r
72 #define EFC_FCMD_EWP 0x03 /* Erase page and write page */
\r
73 #define EFC_FCMD_EWPL 0x04 /* Erase page and write page then lock */
\r
74 #define EFC_FCMD_EA 0x05 /* Erase all */
\r
75 #define EFC_FCMD_EPA 0x07 /* Erase pages */
\r
76 #define EFC_FCMD_SLB 0x08 /* Set Lock Bit */
\r
77 #define EFC_FCMD_CLB 0x09 /* Clear Lock Bit */
\r
78 #define EFC_FCMD_GLB 0x0A /* Get Lock Bit */
\r
79 #define EFC_FCMD_SFB 0x0B /* Set GPNVM Bit */
\r
80 #define EFC_FCMD_CFB 0x0C /* Clear GPNVM Bit */
\r
81 #define EFC_FCMD_GFB 0x0D /* Get GPNVM Bit */
\r
82 #define EFC_FCMD_STUI 0x0E /* Start unique ID */
\r
83 #define EFC_FCMD_SPUI 0x0F /* Stop unique ID */
\r
84 #define EFC_FCMD_GCALB 0x10 /* Get CALIB Bit */
\r
85 #define EFC_FCMD_ES 0x11 /* Erase Sector */
\r
86 #define EFC_FCMD_WUS 0x12 /* Write User Signature */
\r
87 #define EFC_FCMD_EUS 0x13 /* Erase User Signature */
\r
88 #define EFC_FCMD_STUS 0x14 /* Start Read User Signature */
\r
89 #define EFC_FCMD_SPUS 0x15 /* Stop Read User Signature */
\r
91 /* The IAP function entry addreass */
\r
92 #define CHIP_FLASH_IAP_ADDRESS (0x00800008)
\r
98 /*----------------------------------------------------------------------------
\r
99 * Exported functions
\r
100 *----------------------------------------------------------------------------*/
\r
102 extern void EFC_EnableFrdyIt( Efc* efc ) ;
\r
104 extern void EFC_DisableFrdyIt( Efc* efc ) ;
\r
106 extern void EFC_SetWaitState( Efc* efc, uint8_t cycles ) ;
\r
108 extern void EFC_TranslateAddress( Efc** pEfc, uint32_t dwAddress,
\r
109 uint16_t *pwPage, uint16_t *pwOffset ) ;
\r
111 extern void EFC_ComputeAddress( Efc* efc, uint16_t wPage, uint16_t wOffset,
\r
112 uint32_t *pdwAddress ) ;
\r
114 extern uint32_t EFC_PerformCommand( Efc* efc, uint32_t dwCommand,
\r
115 uint32_t dwArgument, uint32_t dwUseIAP ) ;
\r
117 extern uint32_t EFC_GetStatus( Efc* efc ) ;
\r
119 extern uint32_t EFC_GetResult( Efc* efc ) ;
\r
121 extern void EFC_SetFlashAccessMode(Efc* efc, uint32_t dwMode) ;
\r
127 #endif /* #ifndef _EEFC_ */
\r