summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/HAL/include/eeprom.h
blob: a4a21966e74fe5689d337239e69620ef6bf43fad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**************************************************************************//**
  \file  eeprom.h

  \brief The header file describes the EEPROM interface.

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
  History:
    5/12/07 A. Khromykh - Created
 ******************************************************************************/
/******************************************************************************
 *   WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK.  *
 *   EXPERT USERS SHOULD PROCEED WITH CAUTION.                                *
 ******************************************************************************/

#ifndef _EEPROM_H
#define _EEPROM_H

// \cond
/******************************************************************************
                   Includes section
******************************************************************************/
#include <types.h>

/******************************************************************************
                   Define(s) section
******************************************************************************/
#if defined(AT91SAM7X256)
  #define EEPROM_DATA_MEMORY_SIZE 0x400u
#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \
   || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1) \
   || defined(AT91SAM3S4C)
  #define EEPROM_DATA_MEMORY_SIZE 0x1000u
#elif defined(ATXMEGA128A1)
  #define EEPROM_DATA_MEMORY_SIZE 0x800u
#endif
// \endcond

/******************************************************************************
                   Types section
******************************************************************************/
/**************************************************************************//**
\brief eeprom access control structure
******************************************************************************/
typedef struct
{
  /** \brief EEPROM address */
  uint16_t address;
  /** \brief pointer to data memory */
  uint8_t *data;
  /** \brief number of bytes */
  uint16_t length;
} HAL_EepromParams_t;

/******************************************************************************
                   Prototypes section
******************************************************************************/
/******************************************************************************
\brief Reads a number of bytes defined by HAL_EepromParams_t from the EEPROM.
\param[in]
  param - address of HAL_EepromParams_t structure. \n
  fields of structure set by user: \n
  address - eeprom address \n
  data - pointer to data memory \n
  length - number of bytes
\param[in]
  readDone - pointer to the function that will notify about reading completion.
\return
  0 - success, \n
  -1 - the number of bytes to read is too large, \n
  -2 - the previous EEPROM request is not completed yet.
******************************************************************************/
int HAL_ReadEeprom(HAL_EepromParams_t *params, void (*readDone)());

/******************************************************************************
\brief Writes a number of bytes defined by HAL_EepromParams_t to EEPROM.
By writeDone parameter user can control if write operation will be asynchronous
or synchronous.
\param[in]
  param - address of HAL_EepromParams_t structure. \n
  fields of structure set by user: \n
  address - eeprom address \n
  data - pointer to data memory \n
  length - number of bytes
\param[in]
  writeDone - pointer to the function that will notify about writing completion. \n
  Only for avr: \n
  if writeDone is NULL write operation will be synchronous.
\return
  0 - success, \n
  -1 - the number of bytes to write is too large, \n
  -2 - the previous EEPROM request is not completed yet.
******************************************************************************/
int HAL_WriteEeprom(HAL_EepromParams_t *params, void (*writeDone)());

/**************************************************************************//**
\brief Checks the eeprom state.

\return
  true  - eeprom is busy; \n
  false - eeprom is free;
******************************************************************************/
bool HAL_IsEepromBusy(void);

#endif /*_EEPROM_H*/

//eof eeprom.h