Harald Welte | e9eaf90 | 2017-02-26 12:52:01 +0100 | [diff] [blame^] | 1 | /* ----------------------------------------------------------------------------
|
| 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 | /**
|
| 31 | * \file
|
| 32 | *
|
| 33 | * \section Purpose
|
| 34 | *
|
| 35 | * Interface for configuration the Enhanced Embedded Flash Controller (EEFC) peripheral.
|
| 36 | *
|
| 37 | * \section 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 |
|
| 50 | #ifndef _EEFC_
|
| 51 | #define _EEFC_
|
| 52 |
|
| 53 | /*----------------------------------------------------------------------------
|
| 54 | * Headers
|
| 55 | *----------------------------------------------------------------------------*/
|
| 56 | #include "chip.h"
|
| 57 |
|
| 58 | #include <stdint.h>
|
| 59 |
|
| 60 | /*----------------------------------------------------------------------------
|
| 61 | * Definitions
|
| 62 | *----------------------------------------------------------------------------*/
|
| 63 | /* EFC command */
|
| 64 | #define EFC_FCMD_GETD 0x00
|
| 65 | #define EFC_FCMD_WP 0x01
|
| 66 | #define EFC_FCMD_WPL 0x02
|
| 67 | #define EFC_FCMD_EWP 0x03
|
| 68 | #define EFC_FCMD_EWPL 0x04
|
| 69 | #define EFC_FCMD_EA 0x05
|
| 70 | #define EFC_FCMD_SLB 0x08
|
| 71 | #define EFC_FCMD_CLB 0x09
|
| 72 | #define EFC_FCMD_GLB 0x0A
|
| 73 | #define EFC_FCMD_SFB 0x0B
|
| 74 | #define EFC_FCMD_CFB 0x0C
|
| 75 | #define EFC_FCMD_GFB 0x0D
|
| 76 | #define EFC_FCMD_STUI 0x0E /* Start unique ID */
|
| 77 | #define EFC_FCMD_SPUI 0x0F /* Stop unique ID */
|
| 78 |
|
| 79 | /* The IAP function entry addreass */
|
| 80 | #define CHIP_FLASH_IAP_ADDRESS (0x00800008)
|
| 81 |
|
| 82 | #ifdef __cplusplus
|
| 83 | extern "C" {
|
| 84 | #endif
|
| 85 |
|
| 86 | /*----------------------------------------------------------------------------
|
| 87 | * Exported functions
|
| 88 | *----------------------------------------------------------------------------*/
|
| 89 |
|
| 90 | extern void EFC_EnableFrdyIt( Efc* efc ) ;
|
| 91 |
|
| 92 | extern void EFC_DisableFrdyIt( Efc* efc ) ;
|
| 93 |
|
| 94 | extern void EFC_SetWaitState( Efc* efc, uint8_t cycles ) ;
|
| 95 |
|
| 96 | extern void EFC_TranslateAddress( Efc** pEfc, uint32_t dwAddress, uint16_t *pwPage, uint16_t *pwOffset ) ;
|
| 97 |
|
| 98 | extern void EFC_ComputeAddress( Efc* efc, uint16_t wPage, uint16_t wOffset, uint32_t *pdwAddress ) ;
|
| 99 |
|
| 100 | extern void EFC_StartCommand( Efc* efc, uint32_t dwCommand, uint32_t dwArgument ) ;
|
| 101 |
|
| 102 | extern uint32_t EFC_PerformCommand( Efc* efc, uint32_t dwCommand, uint32_t dwArgument, uint32_t dwUseIAP ) ;
|
| 103 |
|
| 104 | extern uint32_t EFC_GetStatus( Efc* efc ) ;
|
| 105 |
|
| 106 | extern uint32_t EFC_GetResult( Efc* efc ) ;
|
| 107 |
|
| 108 | #ifdef __cplusplus
|
| 109 | }
|
| 110 | #endif
|
| 111 |
|
| 112 | #endif /* #ifndef _EEFC_ */
|
| 113 |
|