00001 /****************************************************************************/ 00018 #ifndef _EEPROM_H 00019 #define _EEPROM_H 00020 00021 // \cond 00022 /****************************************************************************** 00023 Includes section 00024 ******************************************************************************/ 00025 #include <types.h> 00026 00027 /****************************************************************************** 00028 Define(s) section 00029 ******************************************************************************/ 00030 #if defined(AT91SAM7X256) 00031 #define EEPROM_DATA_MEMORY_SIZE 0x400u 00032 #elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) 00033 #define EEPROM_DATA_MEMORY_SIZE 0x1000u 00034 #endif 00035 // \endcond 00036 00037 /****************************************************************************** 00038 Types section 00039 ******************************************************************************/ 00040 /**************************************************************************/ 00043 typedef struct 00044 { 00046 uint16_t address; 00048 uint8_t *data; 00050 uint16_t length; 00051 } HAL_EepromParams_t; 00052 00053 /****************************************************************************** 00054 Prototypes section 00055 ******************************************************************************/ 00056 /****************************************************************************** 00057 \brief Reads a number of bytes defined by HAL_EepromParams_t from the EEPROM. 00058 \param[in] 00059 param - address of HAL_EepromParams_t structure. \n 00060 fields of structure set by user: \n 00061 address - eeprom address \n 00062 data - pointer to data memory \n 00063 length - number of bytes 00064 \param[in] 00065 readDone - pointer to the function that will notify about reading completion. 00066 \return 00067 0 - success, \n 00068 -1 - the number of bytes to write is too large, \n 00069 -2 - the previous EEPROM request is not completed yet. 00070 ******************************************************************************/ 00071 int HAL_ReadEeprom(HAL_EepromParams_t *params, void (*readDone)()); 00072 00073 /****************************************************************************** 00074 \brief Writes a number of bytes defined by HAL_EepromParams_t to EEPROM. 00075 By writeDone parameter user can control if write operation will be asynchronous 00076 or synchronous. 00077 \param[in] 00078 param - address of HAL_EepromParams_t structure. \n 00079 fields of structure set by user: \n 00080 address - eeprom address \n 00081 data - pointer to data memory \n 00082 length - number of bytes 00083 \param[in] 00084 writeDone - pointer to the function that will notify about reading completion. \n 00085 Only for avr: \n 00086 if writeDone is NULL write operation will be synchronous. 00087 \return 00088 0 - success, \n 00089 -1 - the number of bytes to write is too large, \n 00090 -2 - the previous EEPROM request is not completed yet. 00091 ******************************************************************************/ 00092 int HAL_WriteEeprom(HAL_EepromParams_t *params, void (*writeDone)()); 00093 00094 /**************************************************************************/ 00101 bool HAL_IsEepromBusy(void); 00102 00103 #endif /*_EEPROM_H*/ 00104 00105 //eof eeprom.h