summaryrefslogtreecommitdiff
path: root/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/common/src/eeprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'digital/beacon/src/Bitcloud_stack/Components/HAL/avr/common/src/eeprom.c')
-rw-r--r--digital/beacon/src/Bitcloud_stack/Components/HAL/avr/common/src/eeprom.c156
1 files changed, 0 insertions, 156 deletions
diff --git a/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/common/src/eeprom.c b/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/common/src/eeprom.c
deleted file mode 100644
index 8e17055b..00000000
--- a/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/common/src/eeprom.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/**************************************************************************//**
- \file eeprom.c
-
- \brief Implementation of 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. *
- ******************************************************************************/
-
-/******************************************************************************
- Includes section
-******************************************************************************/
-#include <halEeprom.h>
-
-/******************************************************************************
- Types section
-******************************************************************************/
-typedef enum
-{
- EEPROM_IDLE = 0,
- EEPROM_BUSY
-} EepromState_t;
-
-/******************************************************************************
- Global variables section
-******************************************************************************/
-EepromState_t halEepromState = EEPROM_IDLE; // state
-HAL_EepromParams_t halEepromParams;
-void (*halEepromDone)();
-
-/******************************************************************************
- Implementations section
-******************************************************************************/
-/******************************************************************************
-Reads some number of bytes defined by HAL_EepromParams_t from the EEPROM.
-Parameters:
- params - address of HAL_EepromParams_t defined by user.
- readDone - callback method
-Returns:
- 0 - success.
- -1 - the EEPROM has request that was not completed,
- number of byte to read too much.
- -2 - eeprom is busy
-******************************************************************************/
-int HAL_ReadEeprom(HAL_EepromParams_t *params, void (*readDone)())
-{
- uint16_t i;
-
- if (EEPROM_IDLE != halEepromState)
- return -2;
- if (NULL == params)
- return -1;
- if ((uint16_t)(params->address + params->length) > EEPROM_DATA_MEMORY_SIZE)
- return -1;
-
- halEepromState = EEPROM_BUSY;
- halEepromDone = readDone;
- halEepromParams = *params;
- halWaitEepromReady(); // wait for completion of previous operation
- for (i = 0; i < halEepromParams.length; i++)
- {
- halEepromParams.data[i] = halReadEeprom(halEepromParams.address++);
- }
- halEepromParams.length = 0;
- halPostTask3(HAL_EE_READY);
-
- return 0;
-}
-
-/******************************************************************************
-Writes number of bytes defined by HAL_EepromParams_t to EEPROM.
-By writeDone parameter user can control if write operation will be asynchronous
-or synchronous.
-Parameters:
- params - address of HAL_EepromParams_t defined by user.
- writeDone - address of callback. if writeDone is NULL write operation will be
- synchronous.
-Returns:
- 0 - success.
- -1 - the EEPROM has request that was not completed,
- number of byte to write too much.
- -2 - eeprom is busy
-******************************************************************************/
-int HAL_WriteEeprom(HAL_EepromParams_t *params, void (*writeDone)())
-{
- uint16_t i;
-
- if (EEPROM_IDLE != halEepromState)
- return -2;
- if (NULL == params)
- return -1;
- if ((uint16_t)(params->address + params->length) > EEPROM_DATA_MEMORY_SIZE)
- return -1;
-
- halEepromState = EEPROM_BUSY;
- halEepromParams = *params;
- halEepromDone = writeDone;
- if (halEepromDone)
- {// asynchronous operation
- halEepromWrite(HAL_EEPROM_WRITE_MASK_INT, halEepromParams.address++, *halEepromParams.data++);
- halEepromParams.length--;
- return 0;
- }
- for (i = 0; i < halEepromParams.length; i++)
- {
- halEepromWrite(HAL_EEPROM_WRITE_MASK, halEepromParams.address++, *halEepromParams.data++);
- }
- halWaitEepromReady(); // wait for completion of previous write
- halEepromState = EEPROM_IDLE;
-
- return 0;
-}
-
-/******************************************************************************
-Checks the eeprom state.
-
-Returns:
- true - eeprom is busy;
- false - eeprom is free;
-******************************************************************************/
-bool HAL_IsEepromBusy(void)
-{
- if (EEPROM_BUSY == halEepromState)
- return true;
- else
- return false;
-}
-
-/******************************************************************************
-Interrupt handler about write completion to EEPROM.
-******************************************************************************/
-void halSigEepromReadyHandler(void)
-{
- if (!halEepromParams.length)
- {
- halEepromState = EEPROM_IDLE;
- if (NULL != halEepromDone)
- halEepromDone();
- return;
- }
- halEepromWrite(HAL_EEPROM_WRITE_MASK_INT, halEepromParams.address++, *halEepromParams.data++);
- halEepromParams.length--;
-}
-//eof eeprom.c