RTEMS 6.1-rc5
Loading...
Searching...
No Matches
efc.h
Go to the documentation of this file.
1/* ---------------------------------------------------------------------------- */
2/* Atmel Microcontroller Software Support */
3/* SAM Software Package License */
4/* ---------------------------------------------------------------------------- */
5/* Copyright (c) 2015, Atmel Corporation */
6/* */
7/* All rights reserved. */
8/* */
9/* Redistribution and use in source and binary forms, with or without */
10/* modification, are permitted provided that the following condition is met: */
11/* */
12/* - Redistributions of source code must retain the above copyright notice, */
13/* this list of conditions and the disclaimer below. */
14/* */
15/* Atmel's name may not be used to endorse or promote products derived from */
16/* this software without specific prior written permission. */
17/* */
18/* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28/* ---------------------------------------------------------------------------- */
29
51#ifndef _EEFC_
52#define _EEFC_
53
54/*----------------------------------------------------------------------------
55 * Headers
56 *----------------------------------------------------------------------------*/
57#include "chip.h"
58
59#include <stdint.h>
60
61/*----------------------------------------------------------------------------
62 * Definitions
63 *----------------------------------------------------------------------------*/
64/* TODO: Temporary definition for missing symbol in header file */
65#define IFLASH_SECTOR_SIZE 65536u
66
67
68/* EFC command */
69#define EFC_FCMD_GETD 0x00 /* Get Flash Descriptor */
70#define EFC_FCMD_WP 0x01 /* Write page */
71#define EFC_FCMD_WPL 0x02 /* Write page and lock */
72#define EFC_FCMD_EWP 0x03 /* Erase page and write page */
73#define EFC_FCMD_EWPL 0x04 /* Erase page and write page then lock */
74#define EFC_FCMD_EA 0x05 /* Erase all */
75#define EFC_FCMD_EPA 0x07 /* Erase pages */
76#define EFC_FCMD_SLB 0x08 /* Set Lock Bit */
77#define EFC_FCMD_CLB 0x09 /* Clear Lock Bit */
78#define EFC_FCMD_GLB 0x0A /* Get Lock Bit */
79#define EFC_FCMD_SFB 0x0B /* Set GPNVM Bit */
80#define EFC_FCMD_CFB 0x0C /* Clear GPNVM Bit */
81#define EFC_FCMD_GFB 0x0D /* Get GPNVM Bit */
82#define EFC_FCMD_STUI 0x0E /* Start unique ID */
83#define EFC_FCMD_SPUI 0x0F /* Stop unique ID */
84#define EFC_FCMD_GCALB 0x10 /* Get CALIB Bit */
85#define EFC_FCMD_ES 0x11 /* Erase Sector */
86#define EFC_FCMD_WUS 0x12 /* Write User Signature */
87#define EFC_FCMD_EUS 0x13 /* Erase User Signature */
88#define EFC_FCMD_STUS 0x14 /* Start Read User Signature */
89#define EFC_FCMD_SPUS 0x15 /* Stop Read User Signature */
90
91/* The IAP function entry address */
92#define CHIP_FLASH_IAP_ADDRESS (0x00800008)
93
94#ifdef __cplusplus
95extern "C" {
96#endif
97
98/*----------------------------------------------------------------------------
99 * Exported functions
100 *----------------------------------------------------------------------------*/
101
102extern void EFC_EnableFrdyIt(Efc *efc);
103
104extern void EFC_DisableFrdyIt(Efc *efc);
105
106extern void EFC_SetWaitState(Efc *efc, uint8_t cycles);
107
108extern void EFC_TranslateAddress(Efc **pEfc, uint32_t dwAddress,
109 uint16_t *pwPage, uint16_t *pwOffset);
110
111extern void EFC_ComputeAddress(Efc *efc, uint16_t wPage, uint16_t wOffset,
112 uint32_t *pdwAddress);
113
114extern uint32_t EFC_PerformCommand(Efc *efc, uint32_t dwCommand,
115 uint32_t dwArgument, uint32_t dwUseIAP);
116
117extern uint32_t EFC_GetStatus(Efc *efc);
118
119extern uint32_t EFC_GetResult(Efc *efc);
120
121extern void EFC_SetFlashAccessMode(Efc *efc, uint32_t dwMode);
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif /* #ifndef _EEFC_ */
128
uint32_t EFC_GetStatus(Efc *efc)
Returns the current status of the EEFC.
Definition: efc.c:157
void EFC_TranslateAddress(Efc **pEfc, uint32_t dwAddress, uint16_t *pwPage, uint16_t *pwOffset)
Translates the given address page and offset values.
Definition: efc.c:182
void EFC_SetFlashAccessMode(Efc *efc, uint32_t dwMode)
Set flash access mode.
Definition: efc.c:273
void EFC_EnableFrdyIt(Efc *efc)
Enables the flash ready interrupt source on the EEFC peripheral.
Definition: efc.c:111
void EFC_DisableFrdyIt(Efc *efc)
Disables the flash ready interrupt source on the EEFC peripheral.
Definition: efc.c:124
void EFC_ComputeAddress(Efc *efc, uint16_t wPage, uint16_t wOffset, uint32_t *pdwAddress)
Computes the address of a flash access given the page and offset.
Definition: efc.c:210
uint32_t EFC_GetResult(Efc *efc)
Returns the result of the last executed command.
Definition: efc.c:167
void EFC_SetWaitState(Efc *efc, uint8_t cycles)
Set read/write wait state on the EEFC peripheral.
Definition: efc.c:139
uint32_t EFC_PerformCommand(Efc *efc, uint32_t dwCommand, uint32_t dwArgument, uint32_t dwUseIAP)
Performs the given command and wait until its completion (or an error).
Definition: efc.c:238
Efc hardware registers.
Definition: component_efc.h:41