summaryrefslogtreecommitdiff
path: root/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private
diff options
context:
space:
mode:
Diffstat (limited to 'digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private')
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsAuxService.h80
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsCrcService.h73
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsDbg.h37
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsMemAbstract.h70
-rw-r--r--digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsWriteData.h84
5 files changed, 344 insertions, 0 deletions
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsAuxService.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsAuxService.h
new file mode 100644
index 00000000..3735afaa
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsAuxService.h
@@ -0,0 +1,80 @@
+/***************************************************************************//**
+ \file pdsAuxService.h
+
+ \brief The header file describes the auxiliary service of Persistence Data Server
+
+ \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:
+ 22/01/08 A. Khromykh - Created
+ 01/11/10 A. Razinkov - Modified
+*****************************************************************************/
+
+#ifndef _PDSAUXSERVICE_H
+#define _PDSAUXSERVICE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#ifndef _MAC2_
+ #include <aps.h>
+ #include <nwk.h>
+ #include <appFramework.h>
+#else // _MAC2_
+ #include <appTimer.h>
+#endif // _MAC2_
+
+/******************************************************************************
+ Define(s) section
+******************************************************************************/
+/* define for eeprom write highlight */
+//#define USE_LED
+
+// crc area
+#define PDS_CRC_AREA 10
+// user area
+#define USER_BASE_EEPROM_ADDRESS (csPersistentMemorySize + PDS_CRC_AREA)
+
+#define PDS_CS_PARAMETER 0
+#define PDS_CS_MEMORY 1
+#define PDS_STOP_SAVE 2
+
+#define EEPROM_BUSY -2
+#define EEPROM_ERROR -1
+
+#define STORE_TIMER_TIMEOUT 300000ul // 5 minutes
+#define SHORT_TIMEOUT 50ul // 50 msec
+#define PDS_LONG_INTERVAL 0
+#define PDS_SHORT_INTERVAL 1
+#define SAVE_IS_STARTED 1
+#define SAVE_IS_STOPED 0
+
+#define MAX_CS_PDS_VARIABLE_SIZE 16
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+// crc property
+typedef struct
+{
+ uint8_t crc;
+ uint16_t position;
+ PDS_DataServerState_t eepromState;
+} PDS_ServiceCrc_t;
+
+/******************************************************************************
+ External global variables section
+******************************************************************************/
+extern HAL_AppTimer_t pdsEepromSaveServiceTimer;
+extern uint8_t savingIsStarted;
+extern const uint8_t csPersistentItemsAmount;
+extern const uint16_t csPersistentMemorySize;
+
+#endif /*_PDSAUXSERVICE_H*/
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsCrcService.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsCrcService.h
new file mode 100644
index 00000000..cf00f9f4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsCrcService.h
@@ -0,0 +1,73 @@
+/***************************************************************************//**
+ \file pdsCrcService.h
+
+ \brief The header file describes the interface of crc counting
+
+ \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:
+ 22/01/08 A. Khromykh - Created
+ 01/11/10 A. Razinkov - Modified
+*****************************************************************************/
+
+#ifndef _PDSCRCSERVICE_H
+#define _PDSCRCSERVICE_H
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <pdsDataServer.h>
+#include <pdsAuxService.h>
+
+#ifdef _COMMISSIONING_
+/******************************************************************************
+ Prototypes section
+******************************************************************************/
+/******************************************************************************
+\brief Calculate CRC of persistent data stored in persist memory
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+void pdsCalculateCrc(PDS_ServiceCrc_t *crcStation);
+
+/******************************************************************************
+\brief Read CRC of stored data from persist memory
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+void pdsReadCrc(PDS_ServiceCrc_t *crcStation);
+
+/******************************************************************************
+\brief Write CRC of stored data to persist memory. The ring buffer used
+\ to increase persist memory life cycle
+\
+\param[out] crcStation - pointer to CRC service structure
+******************************************************************************/
+PDS_DataServerState_t pdsWriteCrc(void);
+
+/******************************************************************************
+\brief Clears whole CRC area in persist memory
+\
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t pdsClearCrcArea(void);
+
+/******************************************************************************
+\brief Check if any valid data exists in persist memory
+\
+\return operation result
+******************************************************************************/
+PDS_DataServerState_t pdsCheckPersistMemory(void);
+
+#ifdef __DBG_PDS__
+ void pdsDbgReadAllEeprom(void);
+#endif
+
+#endif /* _COMMISSIONING_ */
+#endif /*_PDSCRCSERVICE_H*/
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsDbg.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsDbg.h
new file mode 100644
index 00000000..b336095f
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsDbg.h
@@ -0,0 +1,37 @@
+/******************************************************************************
+ \file csDbg.h
+
+ \brief
+ Persistent Data Server debug info
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 29.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _PDSDBG_H_
+#define _PDSDBG_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <dbg.h>
+
+/******************************************************************************
+ Types section
+******************************************************************************/
+
+typedef enum
+{
+ PDS_PDSPREPAREMEMORYACCESS0,
+ PDS_PDSPREPAREMEMORYACCESS1
+} PDS_DbgCodeId_t;
+
+#endif /* CSDBG_H_ */
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsMemAbstract.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsMemAbstract.h
new file mode 100644
index 00000000..ca95f064
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsMemAbstract.h
@@ -0,0 +1,70 @@
+/***************************************************************************//**
+ \file pdsMemAbstract.h
+
+ \brief Memory abstract header
+
+ \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:
+ 6/11/08 A. Khromykh - Created
+*****************************************************************************/
+#ifndef _PDSMEMABSTRACT_H
+#define _PDSMEMABSTRACT_H
+
+/* Type of usage memory */
+#define USE_EEPROM
+
+/* This header file performs persistence memory API redefinition.
+ * The goal is to achieve memory type independence for persist data server (PDS).
+ *
+ *
+ * MEMORY_DESCRIPTOR - persistence memory descriptor. It is a structure type, which
+ * includes the following variables:
+ * uint16_t address - internal persistence memory address to be accessed.
+ * uint8_t *data - pointer to the variable in RAM to be stored (or to be filled
+ * by read value from persistence).
+ * uint16_t length - "data" variable length (bytes). Equal to the number of bytes
+ * to be exchanged between persistence memory and RAM.
+ *
+ *
+ * WRITE_MEMORY, READ_MEMORY - persistence memory access functions. These functions
+ * should have the following form:
+ * int write/read(MEMORY_DESCRIPTOR *memoryDescr, void (*callback)(void));
+ * Parameters:
+ * memoryDescr - pointer to memory descriptor
+ * callback - pointer to callback function. Callback function will be called
+ * after read or write persistence memory operation is completed.
+ * Returns:
+ * 0 - successful access;
+ * -1 - the number of bytes to read (write) is too large.
+ * Persistence memory access functions should perform memory arbitration also, i.e.
+ * memory busy return status is illegal.
+ *
+ *
+ * IS_MEMORY_BUSY - persistence memory access function, should have the following form:
+ * bool isMemoryBusy(void);
+ * Parameters:
+ * none.
+ * Returns:
+ * true - memory is busy
+ * false - memory is free;
+*/
+
+#if defined(USE_EEPROM)
+
+#include <eeprom.h>
+
+#define WRITE_MEMORY HAL_WriteEeprom
+#define READ_MEMORY HAL_ReadEeprom
+#define IS_MEMORY_BUSY HAL_IsEepromBusy
+#define MEMORY_DESCRIPTOR HAL_EepromParams_t
+
+#endif
+
+#endif /* _PDSMEMABSTRACT_H */
diff --git a/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsWriteData.h b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsWriteData.h
new file mode 100644
index 00000000..17cedbc4
--- /dev/null
+++ b/digital/zigbit/bitcloud/stack/Components/PersistDataServer/include/private/pdsWriteData.h
@@ -0,0 +1,84 @@
+/******************************************************************************
+ \file csDbg.h
+
+ \brief
+ Persistent Periodic data save implementation header
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2010 , Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 29.10.10 A. Razinkov - Created.
+******************************************************************************/
+
+#ifndef _PDSWRITEDATA_H_
+#define _PDSWRITEDATA_H_
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <pdsMemAbstract.h>
+
+#ifdef _COMMISSIONING_
+/******************************************************************************
+ Functions prototypes section
+******************************************************************************/
+/******************************************************************************
+\brief Update persistent items values in Configuration Server from persist memory
+\
+\return Operation result
+******************************************************************************/
+PDS_DataServerState_t pdsUpdate(void);
+
+/******************************************************************************
+\brief Locates parameter by it's index in persistent memory table. And prepares
+\ memory descriptor to store parameter's value in EEPROM
+\
+\param[in] index - index of the parameter in persistent memory table
+\param[out]descriptor - memory descriptor to store parameter value
+******************************************************************************/
+void pdsPrepareMemoryAccess(uint8_t index, MEMORY_DESCRIPTOR* descriptor);
+
+/******************************************************************************
+\brief Timer callback, initiates the commit process.
+******************************************************************************/
+void pdsOnTimerSave(void);
+
+/*******************************************************************************
+\brief Start server work
+*******************************************************************************/
+void pdsStartPersistServer(void);
+#endif /* _COMMISSIONING_ */
+
+/******************************************************************************
+\brief Writes data to persist memory
+\
+\param[in] descriptor - memory descriptor to store parameter value
+\param[out]callback - callback to write-finidhed event handler
+******************************************************************************/
+PDS_DataServerState_t pdsWrite(MEMORY_DESCRIPTOR* descriptor, void (*callback)(void));
+
+/******************************************************************************
+\brief Read data from persist memory
+\
+\param[in] descriptor - memory descriptor to read parameter value
+\param[out]callback - callback to read-finished event handler
+******************************************************************************/
+PDS_DataServerState_t pdsRead(MEMORY_DESCRIPTOR* descriptor, void (*callback)(void));
+
+/******************************************************************************
+\brief Wait until memory be ready for transaction
+******************************************************************************/
+void pdsWaitMemoryFree(void);
+
+/*******************************************************************************
+\brief Dummy callback
+*******************************************************************************/
+void pdsDummyCallback(void);
+
+#endif /* _PDSWRITEDATA_H_ */