EVE 1.0
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
arch-eeprom.h
Go to the documentation of this file.
1
#ifndef EVE_ARCH_EEPROM_H_INCLUDED
2
#define EVE_ARCH_EEPROM_H_INCLUDED
3
/**********************************************************************/
4
/*
5
* Copyright (c) 2015-2017, Jetro AS
6
* All rights reserved.
7
*
8
* Redistribution and use in source and binary forms, with or without modification,
9
* are permitted provided that the following conditions are met:
10
*
11
* 1. Redistributions of source code must retain the above copyright notice,
12
* this list of conditions and the following disclaimer.
13
* 2. Redistributions in binary form must reproduce the above copyright notice,
14
* this list of conditions and the following disclaimer in the documentation
15
* and/or other materials provided with the distribution.
16
* 3. The name of the author may not be used to endorse or promote products
17
* derived from this software without specific prior written permission.
18
*
19
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONRIBUTORS ``AS IS'' AND ANY EXPRESS
20
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
22
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28
* OF SUCH DAMAGE.
29
*
30
* This file is part of the EVE platform.
31
*/
32
33
/**
34
* \file
35
* \brief Driver for EEPROM emulation layer.
36
*
37
* \author DT, Jetro AS
38
*/
/******************************************************************/
39
40
#include <stdint.h>
41
#include <stdbool.h>
42
43
/**
44
* \defgroup eeprom_emu EEPROM emulation driver
45
* \ingroup abstract
46
* \{ */
47
48
/** EEPROM private state */
49
struct
eeprom_state_t
{
50
uint16_t
read_page
;
/**< Current read element in the read bank */
51
uint16_t
write_page
;
/**< Current write element in the write bank */
52
uint8_t
read_bank
;
/**< Index of the bank currently in use for read op. */
53
uint8_t
write_bank
;
/**< Tndex of the bank currently in use for write op. */
54
bool
opened
;
/**< True if the EEPROM was successfully opened */
55
};
56
57
/** EEPROM vtbl */
58
struct
eeprom_vtbl_t
{
59
bool (*Power)(
bool
On);
60
void (*Erase)(uint32_t SectorIndex);
61
void (*Write)(uint32_t DstAddress,
const
void
*SrcBuffer, uint32_t ByteCount);
62
void (*Read)(
void
*DstBuffer, uint32_t SrcAddress, uint32_t ByteCount);
63
};
64
65
/** EEPROM object */
66
struct
eeprom_t
{
67
struct
eeprom_state_t
*
State
;
/**< Pointer to the eeprom private state variable */
68
const
struct
eeprom_vtbl_t
*
Vtbl
;
/**< Virtual function table. Ext flash family is used if not set */
69
eeprom_addr_t
BeginAddr
;
/**< Start address in the EEPROM block */
70
eeprom_addr_t
EndAddr
;
/**< Last address in the EEPROM bank _plus_1_(!) */
71
uint16_t
StartSector
;
/**< The sector in the flash where the EEPROM starts */
72
uint16_t
PageSize
;
/**< Size of the EEPROM page */
73
uint16_t
PagesPerSector
;
/**< Number of EEPROM pages in the flash sector */
74
uint8_t
PagesPerEeprom
;
/**< Number of pages in the EEPROM representation */
75
};
76
77
extern
const
struct
eeprom_t
EepromTable[];
78
extern
const
uint8_t EepromTableSize;
79
80
extern
const
struct
eeprom_vtbl_t
EepromInExternalFlash;
81
extern
const
struct
eeprom_vtbl_t
EepromInInternalFlash;
82
83
/** \} eeprom */
84
85
#endif
/* EVE_ARCH_EEPROM_H_INCLUDED */
eeprom_t::EndAddr
eeprom_addr_t EndAddr
Definition:
arch-eeprom.h:70
eeprom_state_t::opened
bool opened
Definition:
arch-eeprom.h:54
eeprom_t::StartSector
uint16_t StartSector
Definition:
arch-eeprom.h:71
eeprom_t::Vtbl
const struct eeprom_vtbl_t * Vtbl
Definition:
arch-eeprom.h:68
eeprom_vtbl_t
Definition:
arch-eeprom.h:58
eeprom_t::BeginAddr
eeprom_addr_t BeginAddr
Definition:
arch-eeprom.h:69
eeprom_t::PagesPerSector
uint16_t PagesPerSector
Definition:
arch-eeprom.h:73
eeprom_state_t::read_bank
uint8_t read_bank
Definition:
arch-eeprom.h:52
eeprom_t::PagesPerEeprom
uint8_t PagesPerEeprom
Definition:
arch-eeprom.h:74
eeprom_t::PageSize
uint16_t PageSize
Definition:
arch-eeprom.h:72
eeprom_state_t
Definition:
arch-eeprom.h:49
eeprom_t::State
struct eeprom_state_t * State
Definition:
arch-eeprom.h:67
eeprom_state_t::write_bank
uint8_t write_bank
Definition:
arch-eeprom.h:53
eeprom_state_t::write_page
uint16_t write_page
Definition:
arch-eeprom.h:51
eeprom_t
Definition:
arch-eeprom.h:66
eeprom_state_t::read_page
uint16_t read_page
Definition:
arch-eeprom.h:50
Core
Include
dev
arch-eeprom.h
Generated on Thu Mar 30 2017 10:16:55 for EVE 1.0 by
1.8.11