Commit f7df784c authored by Projects's avatar Projects

Initial commit for FreeRTOS.

parent 8b27330a
/***************************************************************************//**
* @file
* @brief General Purpose IO (GPIO) interrupt dispatcher API
* @author Energy Micro AS
* @version 3.20.2
*******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
******************************************************************************/
#ifndef __EMDRV_GPIOINTERRUPT_H
#define __EMDRV_GPIOINTERRUPT_H
#include "stdint.h"
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup EM_Drivers
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup GPIOINT
* @brief General Purpose Input/Output (GPIO) Interrupt Dispatcher API
* @{
******************************************************************************/
/*******************************************************************************
******************************* TYPEDEFS **********************************
******************************************************************************/
/**
* @brief
* GPIO interrupt callback function pointer.
* @details
* Parameters:
* @li pin - The pin index the callback function is invoked for.
*/
typedef void (*GPIOINT_IrqCallbackPtr_t)(uint8_t pin);
/*******************************************************************************
****************************** PROTOTYPES *********************************
******************************************************************************/
void GPIOINT_Init(void);
void GPIOINT_CallbackRegister(uint8_t pin, GPIOINT_IrqCallbackPtr_t callbackPtr);
static __INLINE void GPIOINT_CallbackUnRegister(uint8_t pin);
/***************************************************************************//**
* @brief
* Unregisters user callback for given pin number.
*
* @details
* Use this function to unregister a callback.
*
* @param[in] pin
* Pin number for the callback.
*
******************************************************************************/
static __INLINE void GPIOINT_CallbackUnRegister(uint8_t pin)
{
GPIOINT_CallbackRegister(pin,0);
}
/** @} (end addtogroup GPIOINT */
/** @} (end addtogroup EM_Drivers) */
#ifdef __cplusplus
}
#endif
#endif /* __EMDRV_GPIOINTERRUPT_H */
/***************************************************************************//**
* @file
* @brief General Purpose IO (GPIO) interrupt dispatcher.
* @author Energy Micro AS
* @version 3.20.2
*
*******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
******************************************************************************/
#include "em_gpio.h"
#include "em_int.h"
#include "gpiointerrupt.h"
#include "em_assert.h"
/***************************************************************************//**
* @addtogroup EM_Drivers
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup GPIOINT
* @brief General Purpose Input/Output (GPIO) Interrupt Dispatcher API
* @details
* This is a GPIO interrupt dispatcher module. It consists of gpiointerrupt.c
* and gpiointerrupt.h. EFM32 has two GPIO interrupts (Odd and Even). If more
* than two interrupts are used then interrupt routine must dispatch. This
* driver provides small dispatcher for both GPIO interrupts enabling
* handling of up to 16 GPIO pin interrupts.
*
* It is up to the user to set up and enable interrupt on given pin. Dispatcher
* handles cleaning of interrupt flags.
*
* In order to use GPIO Interrupt Dispatcher it has to be initialized first by
* calling GPIOINT_Init(). Then each pin must be configured by first registering
* the callback for given pin (GPIOINT_CallbackRegister()) and then setting up
* and enabling the interrupt in GPIO module.
* @{
******************************************************************************/
/*******************************************************************************
******************************** MACROS ***********************************
******************************************************************************/
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/* Macro return index of the LSB flag which is set. */
#define GPIOINT_MASK2IDX(mask) (__CLZ(__RBIT(mask)))
/** @endcond */
/*******************************************************************************
******************************* STRUCTS ***********************************
******************************************************************************/
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
typedef struct
{
/* Pin number in range of 0 to 15 */
uint32_t pin;
/* Pointer to the callback function */
GPIOINT_IrqCallbackPtr_t callback;
} GPIOINT_CallbackDesc_t;
/*******************************************************************************
******************************** GLOBALS **********************************
******************************************************************************/
/* Array of user callbacks. One for each pin. */
static GPIOINT_IrqCallbackPtr_t gpioCallbacks[16] = {0};
/*******************************************************************************
****************************** PROTOTYPES *********************************
******************************************************************************/
static void GPIOINT_IRQDispatcher(uint32_t iflags);
/** @endcond */
/*******************************************************************************
*************************** GLOBAL FUNCTIONS ******************************
******************************************************************************/
/***************************************************************************//**
* @brief
* Initialization of GPIOINT module.
*
******************************************************************************/
void GPIOINT_Init(void)
{
NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
NVIC_EnableIRQ(GPIO_ODD_IRQn);
NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
NVIC_EnableIRQ(GPIO_EVEN_IRQn);
}
/***************************************************************************//**
* @brief
* Registers user callback for given pin number.
*
* @details
* Use this function to register a callback which shall be called upon
* interrupt generated from given pin number (port is irrelevant). Interrupt
* itself must be configured externally. Function overwrites previously
* registered callback.
*
* @param[in] pin
* Pin number for the callback.
* @param[in] callbackPtr
* A pointer to callback function.
******************************************************************************/
void GPIOINT_CallbackRegister(uint8_t pin, GPIOINT_IrqCallbackPtr_t callbackPtr)
{
INT_Disable();
/* Dispatcher is used */
gpioCallbacks[pin] = callbackPtr;
INT_Enable();
}
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/***************************************************************************//**
* @brief
* Function calls users callback for registered pin interrupts.
*
* @details
* This function is called when GPIO interrupts are handled by the dispatcher.
* Function gets even or odd interrupt flags and calls user callback
* registered for that pin. Function iterates on flags starting from MSB.
*
* @param iflags
* Interrupt flags which shall be handled by the dispatcher.
*
******************************************************************************/
static void GPIOINT_IRQDispatcher(uint32_t iflags)
{
uint32_t irqIdx;
/* check for all flags set in IF register */
while(iflags)
{
irqIdx = GPIOINT_MASK2IDX(iflags);
/* clear flag*/
iflags &= ~(1 << irqIdx);
if (gpioCallbacks[irqIdx])
{
/* call user callback */
gpioCallbacks[irqIdx](irqIdx);
}
}
}
/***************************************************************************//**
* @brief
* GPIO EVEN interrupt handler. Interrupt handler clears all IF even flags and
* call the dispatcher passing the flags which triggered the interrupt.
*
******************************************************************************/
void GPIO_EVEN_IRQHandler(void)
{
uint32_t iflags;
/* Get all even interrupts. */
iflags = GPIO_IntGetEnabled() & 0x00005555;
/* Clean only even interrupts. */
GPIO_IntClear(iflags);
GPIOINT_IRQDispatcher(iflags);
}
/***************************************************************************//**
* @brief
* GPIO ODD interrupt handler. Interrupt handler clears all IF odd flags and
* call the dispatcher passing the flags which triggered the interrupt.
*
******************************************************************************/
void GPIO_ODD_IRQHandler(void)
{
uint32_t iflags;
/* Get all odd interrupts. */
iflags = GPIO_IntGetEnabled() & 0x0000AAAA;
/* Clean only even interrupts. */
GPIO_IntClear(iflags);
GPIOINT_IRQDispatcher(iflags);
}
/** @endcond */
/** @} (end addtogroup GPIOINT */
/** @} (end addtogroup EM_Drivers) */
/***************************************************************************//**
* @file
* @brief Non-Volatile Memory Manager.
* @author Energy Micro AS
* @version 3.20.2
* @details
* This is a software manager module for non-volatile memory. It consists of
* nvm.c, nvm.h and nvm_hal.h. In addition to this it requires a valid nvm_hal.c.
* This lets the manager work with different types of memory.
* Files nvm_config_template.* shows possible configuration of objects and could
* be used as template for customer application.
*
* The module has the following public interfaces:
*
* NVM_Init()
* NVM_Erase()
* NVM_Write()
* NVM_Read()
* NVM_WearLevel()
*
* Users have to be aware of the following limitations of the module:
* - Maximum 254 objects in a page and 256 pages (limited by uint8_t).
*
*******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __NVM_H
#define __NVM_H
#include <stdint.h>
#include <stdbool.h>
/* needed to get CPU flash size and calculate page size */
#include "em_device.h"
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup EM_Drivers
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup NVM
* @{
******************************************************************************/
/*******************************************************************************
******************************* DEFINES ***********************************
******************************************************************************/
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/** Certain features can be turned on and off on compile time to make the API
* faster, save RAM and flash space. Set it to TRUE to turn the feature on. */
/** Without this define the wear pages are no longer supported. */
#define NVM_FEATURE_WEAR_PAGES_ENABLED true
/** Include and activate the static wear leveling functionality. */
#define NVM_FEATURE_STATIC_WEAR_ENABLED true
/** The threshold used to decide when to do static wear leveling.*/
#define NVM_STATIC_WEAR_THRESHOLD 100
/** Validate data against checksums on every read operation. */
#define NVM_FEATURE_READ_VALIDATION_ENABLED true
/** Validate data against checksums after every write operation. */
#define NVM_FEATURE_WRITE_VALIDATION_ENABLED true
/** Include the NVM_WearLevelGet function. */
#define NVM_FEATURE_WEARLEVELGET_ENABLED true
/** Check if data has been updated before writing update to the NVM. */
#define NVM_FEATURE_WRITE_NECESSARY_CHECK_ENABLED true
/** define maximum number of flash pages that can be used as NVM */
#define NVM_MAX_NUMBER_OF_PAGES 32
/** Calculate page size. */
#if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
#define NVM_PAGE_SIZE (FLASH_SIZE < (512 * 1024) ? 2048 : 4096)
#else
/* _EFM32_GECKO_FAMILY || _EFM32_TINY_FAMILY */
#define NVM_PAGE_SIZE (512)
#endif
/** All objects are written from RAM. */
#define NVM_WRITE_ALL_CMD 0xff
/** All objects are copied from the old page. */
#define NVM_WRITE_NONE_CMD 0xfe
/** All objects are read to RAM. */
#define NVM_READ_ALL_CMD 0xff
/** Retains the registered erase count when eraseing a page. */
#define NVM_ERASE_RETAINCOUNT 0xffffffffUL
/** Structure defining end of pages table. */
#define NVM_PAGE_TERMINATION { NULL, 0, (NVM_Object_Ids) 0 }
/** @endcond */
/*******************************************************************************
****************************** TYPEDEFS ***********************************
******************************************************************************/
/** Enum describing the type of logical page we have; normal or wear. */
typedef enum
{
nvmPageTypeNormal = 0, /**< Normal page, always rewrite. */
nvmPageTypeWear = 1 /**< Wear page. Can be used several times before rewrite. */
} NVM_Page_Type_t;
/** Describes the properties of an object in a page. */
typedef struct
{
uint8_t * location; /**< A pointer to the location of the object in RAM. */
uint16_t size; /**< The size of the object in bytes. */
uint8_t objectId; /**< An object ID used to reference the object. Must be unique in the page. */
} NVM_Object_Descriptor_t;
/** A collection of object descriptors that make up a page. */
typedef NVM_Object_Descriptor_t NVM_Page_t[];
/** Describes the properties of a page. */
typedef struct
{
uint8_t pageId; /**< A page ID used when referring to the page. Must be unique. */
NVM_Page_t const * page; /**< A pointer to the list of all the objects in the page. */
uint8_t pageType; /**< The type of page, normal or wear. */
} NVM_Page_Descriptor_t;
/** The list of pages registered for use. */
typedef NVM_Page_Descriptor_t NVM_Page_Table_t[];
/** Configuration structure. */
typedef struct
{ NVM_Page_Table_t const *nvmPages; /**< Pointer to table defining NVM pages. */
uint8_t const pages; /**< Total number of physical pages. */
uint8_t const userPages; /**< Number of defined (used) pages. */
uint8_t const *nvmArea; /**< Pointer to nvm area in flash. */
} NVM_Config_t;
/** Result type for all the API functions. */
typedef enum
{
nvmResultOk = 0, /**< Flash read/write/erase successful. */
nvmResultAddrInvalid = 1, /**< Invalid address. Write to an address out of
* bounds. */
nvmResultInputInvalid = 2, /**< Invalid input data. */
nvmResultDataInvalid = 3, /**< Invalid data. */
nvmResultWriteLock = 4, /**< A write is currently in progress, and any
* concurrent operations might cause problems. */
nvmResultNoPages = 5, /**< Initialization didn't find any pages. */
nvmResultNoPage = 6, /**< Could not find the specified page. It
* might not have been saved yet. */
nvmResultErrorInitial = 7, /**< Result not changed to OK. */
nvmResultError = 8 /**< General error. */
} NVM_Result_t;
/*******************************************************************************
*************************** PROTOTYPES ************************************
******************************************************************************/
NVM_Result_t NVM_Init(NVM_Config_t const *nvmConfig);
NVM_Result_t NVM_Erase(uint32_t erasureCount);
NVM_Result_t NVM_Write(uint16_t pageId, uint8_t objectId);
NVM_Result_t NVM_Read(uint16_t pageId, uint8_t objectId);
#ifndef NVM_FEATURE_WEARLEVELGET_ENABLED
#define NVM_FEATURE_WEARLEVELGET_ENABLED true
#endif
#if (NVM_FEATURE_WEARLEVELGET_ENABLED == true)
uint32_t NVM_WearLevelGet(void);
#endif
/** @} (end defgroup NVM) */
/** @} (end addtogroup EM_Drivers) */
#ifdef __cplusplus
}
#endif
#endif /* __NVM_H */
/***************************************************************************//**
* @file
* @brief Non-Volatile Memory driver configuration template.
* @author Energy Micro AS
* @version 3.20.2
*******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __NVM_CONFIG_H__
#define __NVM_CONFIG_H__
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup EM_Drivers
* @{
******************************************************************************/
/***************************************************************************//**
* @defgroup NVM
* @{
******************************************************************************/
/*******************************************************************************
**************************** CONFIGURATION ********************************
******************************************************************************/
/** Configure maximum amount of pages for use. */
#define NVM_PAGES 3
/** Configure extra pages to allocate for data security and wear leveling.
* Minimum 1, but the more you add the better lifetime your system will have. */
#define NVM_PAGES_SCRATCH 3
/** Configure where in memory to start storing data. This area should be
* reserved using the linker and needs to be aligned with the physical page
* grouping of the device.
*
* For the internal flash in the Gecko and Tiny Gecko MCUs, the flash pages are
* 512 bytes long. This means that the start location must be a multiple of
* 512 bytes, and that an area equal to 512 bytes * the number of pages and
* scratch page must be reserved here. */
#define NVM_START_LOCATION (FLASH_SIZE - ((NVM_PAGES + NVM_PAGES_SCRATCH) * NVM_PAGE_SIZE))
/** Certain features can be turned on and off on compile time to make the API
* faster, save RAM and flash space. Set it to TRUE to turn the feature on. */
/* Without this define the wear pages are no longer supported. */
#define NVM_FEATURE_WEAR_PAGES_ENABLED true
/* Include and activate the static wear leveling functionality. */
#define NVM_FEATURE_STATIC_WEAR_ENABLED true
/* The threshold used to decide when to do static wear leveling.*/
#define NVM_STATIC_WEAR_THRESHOLD 100
/* Validate data against checksums on every read operation. */
#define NVM_FEATURE_READ_VALIDATION_ENABLED true
/* Validate data against checksums after every write operation. */
#define NVM_FEATURE_WRITE_VALIDATION_ENABLED true
/* Include the NVM_WearLevelGet function. */
#define NVM_FEATURE_WEARLEVELGET_ENABLED true
/* Check if data has been updated before writing update to the NVM. */
#define NVM_FEATURE_WRITE_NECESSARY_CHECK_ENABLED true
/*******************************************************************************
****************************** TYPEDEFS ***********************************
******************************************************************************/
/* Object IDs.
* Enum used to store IDs in a readable format. */
typedef enum
{
FIRST_TABL_ID,
SINGL_VAR_ID,
SECOND_TABL_ID,
WEAR_TABL_ID
} NVM_Object_Ids;
/* Page IDs.
* Enum used to store IDs in a readable format. */
typedef enum
{
FIRST_PAGE_ID,
SECOND_PAGE_ID,
WEAR_PAGE_ID
} NVM_Page_Ids;
/*******************************************************************************
************************** GLOBAL VARIABLES *******************************
******************************************************************************/
/* Make the variables accessible for the entire project. */
extern uint32_t nvmFirstTable[];
extern uint32_t nvmSingleVariable;
extern uint32_t nvmSecondTable[];
extern uint8_t nvmWearTable[];
/** @} (end defgroup NVM) */
/** @} (end addtogroup EM_Drivers) */
#ifdef __cplusplus
}
#endif
#endif /* __NVM_CONFIG_H__ */
/***************************************************************************//**
* @file
* @brief Non-Volatile Memory HAL.
* @author Energy Micro AS
* @version 3.20.2
*******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#ifndef __NVMHAL_H
#define __NVMHAL_H
#include <stdbool.h>
#include "nvm.h"
/* Defines for changing HAL functionality. These are both a bit experimental,
* but should work properly. */
/* Custom write and format methods based on the emlib are used in place of
* the originals. These methods put the CPU to sleep by going to EM1 while the
* operation progresses.
*
* NVMHAL_SLEEP_FORMAT and NVMHAL_SLEEP_WRITE is only used for toggling
* which function is called, and includes about the same amount of code. */
/** Use energy saving version of format function */
#ifndef NVMHAL_SLEEP_FORMAT
#define NVMHAL_SLEEP_FORMAT false
#endif
/** Use energy saving version of write function */
#ifndef NVMHAL_SLEEP_WRITE
#define NVMHAL_SLEEP_WRITE false
#endif
/** DMA read uses the DMA to read data from flash. This also works, but takes a
* bit more time than the usual reading operations, while not providing a high
* amount of power saving since read operations are normally very fast. */
#ifndef NVMHAL_DMAREAD
#define NVMHAL_DMAREAD false
#endif
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
#define NVMHAL_SLEEP (NVMHAL_SLEEP_FORMAT | NVMHAL_SLEEP_WRITE)
/** @endcond */
#include "em_device.h"
#if (NVMHAL_SLEEP == true)
#include "em_msc.h"
#include "em_dma.h"
#include "em_cmu.h"
#include "em_emu.h"
#include "em_int.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
****************************** CONSTANTS **********************************
******************************************************************************/
/*******************************************************************************
***************************** PROTOTYPES **********************************
******************************************************************************/
void NVMHAL_Init(void);
void NVMHAL_DeInit(void);
void NVMHAL_Read(uint8_t *pAddress, void *pObject, uint16_t len);
NVM_Result_t NVMHAL_Write(uint8_t *pAddress, void const *pObject, uint16_t len);
NVM_Result_t NVMHAL_PageErase(uint8_t *pAddress);
void NVMHAL_Checksum(uint16_t *checksum, void *pMemory, uint16_t len);
#ifdef __cplusplus
}
#endif
#endif /* __NVMHAL_H */
This diff is collapsed.
/***************************************************************************//**
* @file
* @brief Non-Volatile Memory Driver configuration.
* @author Energy Micro AS
* @version 3.20.2
*******************************************************************************
* @section License
* <b>(C) Copyright 2013 Energy Micro AS, http://www.energymicro.com</b>
*******************************************************************************
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
* 4. The source and compiled code may only be used on Energy Micro "EFM32"
* microcontrollers and "EFR4" radios.
*
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
* obligation to support this Software. Energy Micro AS is providing the
* Software "AS IS", with no express or implied warranties of any kind,
* including, but not limited to, any implied warranties of merchantability
* or fitness for any particular purpose or warranties against infringement
* of any proprietary rights of a third party.
*
* Energy Micro AS will not be liable for any consequential, incidental, or
* special damages, or any other relief, or for any claim by any third party,
* arising from your use of this Software.
*
*****************************************************************************/
#include "nvm.h"
/***************************************************************************//**
* @addtogroup EM_Drivers
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup NVM
* @{
******************************************************************************/
/*******************************************************************************
******************************* CONFIG ************************************
******************************************************************************/
/* Objects. */
uint32_t nvmFirstTable[20] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
uint32_t nvmSingleVariable = 32;
/* Page definition.
* Combine objects with their id, and put them in a page. */
NVM_Page_t const nvmFirstPage =
{
/*{Pointer to object, Size of object, Object ID}, */
{ (uint8_t *) nvmFirstTable, sizeof(nvmFirstTable), FIRST_TABL_ID },
{ (uint8_t *) &nvmSingleVariable, sizeof(nvmSingleVariable), SINGL_VAR_ID },
NVM_PAGE_TERMINATION /* Null termination of table. Do not remove! */
};
/* Objects. */
uint32_t nvmSecondTable[20] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
/* Page definition.
* Combine objects with their id, and put them in a page. */
NVM_Page_t const nvmSecondPage =
{
/*{Pointer to object, Size of object, Object ID}, */
{ (uint8_t *) nvmSecondTable, sizeof(nvmSecondTable), SECOND_TABL_ID },
NVM_PAGE_TERMINATION /* Null termination of table. Do not remove! */
};
/* Objects. */
uint8_t nvmWearTable[] = { 1, 2, 3, 4, 5 };
/* Page definition.
* Combine objects with their id, and put them in a page.
* This page contains only one object, since it is going to be
* used as a wear page. */
NVM_Page_t const nvmWearPage =
{
/*{Pointer to object, Size of object, Object ID}, */
{ (uint8_t *) nvmWearTable, sizeof(nvmWearTable), WEAR_TABL_ID },
NVM_PAGE_TERMINATION /* Null termination of table. Do not remove! */
};
/* Register pages.
* Connect pages to page IDs, and define the type of page. */
NVM_Page_Table_t const nvmPages =
{
/*{Page ID, Page pointer, Page type}, */
{ FIRST_PAGE_ID, &nvmFirstPage, nvmPageTypeNormal },
{ SECOND_PAGE_ID, &nvmSecondPage, nvmPageTypeNormal },
{ WEAR_PAGE_ID, &nvmWearPage, nvmPageTypeWear }
};
/** @} (end addtogroup NVM */
/** @} (end addtogroup EM_Drivers) */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that has become a de facto standard. *
* *
* Help yourself get started quickly and support the FreeRTOS *
* project by purchasing a FreeRTOS tutorial book, reference *
* manual, or both from: http://www.FreeRTOS.org/Documentation *
* *
* Thank you! *
* *
***************************************************************************
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
>>! NOTE: The modification to the GPL is included to allow you to distribute
>>! a combined work that includes FreeRTOS without being obliged to provide
>>! the source code for proprietary components outside of the FreeRTOS
>>! kernel.
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available from the following
link: http://www.freertos.org/a00114.html
1 tab == 4 spaces!
***************************************************************************
* *
* Having a problem? Start by reading the FAQ "My application does *
* not run, what could be wrong?" *
* *
* http://www.FreeRTOS.org/FAQHelp.html *
* *
***************************************************************************
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
license and Real Time Engineers Ltd. contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef PROJDEFS_H
#define PROJDEFS_H
/* Defines the prototype to which task functions must conform. */
typedef void (*pdTASK_CODE)( void * );
#define pdFALSE ( ( portBASE_TYPE ) 0 )
#define pdTRUE ( ( portBASE_TYPE ) 1 )
#define pdPASS ( pdTRUE )
#define pdFAIL ( pdFALSE )
#define errQUEUE_EMPTY ( ( portBASE_TYPE ) 0 )
#define errQUEUE_FULL ( ( portBASE_TYPE ) 0 )
/* Error definitions. */
#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 )
#define errNO_TASK_TO_RUN ( -2 )
#define errQUEUE_BLOCKED ( -4 )
#define errQUEUE_YIELD ( -5 )
#endif /* PROJDEFS_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment