⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nv_data.h

📁 FREESCALE的基于802.15.4无线通讯原代码
💻 H
字号:
/*****************************************************************************
* This module contains the header information for NV Data module
*
* Note!! The specified link sequence is very important for the allocation of
* NV RAM 
* A changed link sequence can change the NV RAM layout and the pointer cannot
*        read the correct NV RAM data.
*
* c) Copyright 2005, Freescale, Inc. All rights reserved.
*
* Freescale Semiconductor Confidential Proprietary
*
* No part of this document must be reproduced in any form - including copied,
* transcribed, printed or by any electronic means - without specific written
* permission from Freescale Semiconductor Danmark A/S.
*****************************************************************************/

#ifndef _NV_DATA_H_
#define _NV_DATA_H_

#include "EmbeddedTypes.h"

#define gNV_FlashIncluded_d FALSE
#ifdef PLATFORM_WINDOWS
	#define _CONST
#else
	#define _CONST   const
#endif PLATFORM_WINDOWS



/*****************************************************************************
******************************************************************************
* Private macros
******************************************************************************
*****************************************************************************/

#define PLACE_CONST_SEG(segment)  CONST_SEG segment
#define RESTORE_CONST_SEG         CONST_SEG DEFAULT
#define PLACE_DATA_SEG(segment)   DATA_SEG segment
#define RESTORE_DATA_SEG          DATA_SEG DEFAULT

#define gNVMSectorSize_c          512
/* These address MUST be the same as the ones in Linker file.Be carefull!!!*/
#define NvramScratchpadAddress_c  (uint16_t)gScratchPadNvram
#define NvramMacAddress_c         (uint16_t)Freescale_Copyright
#define NvramZS1Address_c         (uint16_t)gZS1Nvram
#define NvramZS2Address_c         (uint16_t)gZS2Nvram


#define NvramScratchpadSize_c (sizeof(NvramStruct_t))
#define NvramSize_c           (sizeof(NvramStruct_t))

#define gNVMDataPerSector_c   506
#define pStoredNvram0_c       (( void* )NvramScratchpadAddress_c )

#define pStoredNvram1_c       (( void* )NvramMacAddress_c )
#define pStoredNvram2_c       (( void* )( NvramZS1Address_c - 150 ))

#define pStoredNvram3_c       (( void* )NvramZS2Address_c )


/* System flag to detect a full copied section  */
#define NvramSystemFlag_c         ((uint8_t)0x55)
#define ErasedByte_c              ((uint8_t)0xFF)
#define ErasedWord_c              ((uint16_t)0xFFFF)

/* Sector number must match address above */															 
#define NvramScratchpad_c         NvramScratchpadAddress_c >> HCS08SectorSize_c 
#define NvramMac_c                NvramMacAddress_c >> HCS08SectorSize_c
#define NvramZS2_c                NvramZS2Address_c >>  HCS08SectorSize_c 
#define NvramZS1_c                ( NvramZS2_c ) - 1 


/* Values for Abel register 0x04  */
#define ABEL_CCA_ENERGY_DETECT_THRESHOLD 0x9600 /*  MSB=CCA Energy detect
                  threshold: abs(power in dBm)*2, 0x96=-75dBm, 0x82=-65dBm */
#define ABEL_POWER_COMPENSATION_OFFSET   0x0074 /*  LSB=Power compensation
           Offset added to RSSI. Typical 0x74 FFJ/JK 13/01/04 (Abel 013)  */

extern volatile uint8_t gNVMCriticalSectionActiveFlag;

#define gNumOfZigBeeSectors_c 2

/************************************************************************************
* Check if NVM write operation can be done or not.
*
* If the NVMCriticalSectionActiveFlag has a non-zero value then BeeStack is busy in
* data transmisxsion. NVM save is delayed till it finishes data transmission.
*  
* Interface assumptions:
*   None
*   
* Return value:
*   TRUE if it is Ok to do NVM write operation else FLASE
* 
* Revision history:
*   date      Author    Comments
*   ------    ------    --------
*   230606    SP        Created
* 
************************************************************************************/
           
#define NVM_CheckNVMWriteAccess() !gNVMCriticalSectionActiveFlag

           
/*****************************************************************************
* Register 0x0A, bit (15:8)  
* Xtal trim - crystal oscillator capacitor trim  
* Setting       AbelX.X  
* ---------    ------------  
*   0x00         Default from reset  
*****************************************************************************/           
#define ABEL_XTAL_TRIM (0x36 << 8) /* MSB */

/*****************************************************************************
* Register 0x0A, bit (7:6) 
* Xtal bias - crystal oscillator bias adjustment 
* Setting       Abel2.0            Abel2.1 
* ---------    ------------       ------------ 
*   00           5 (Doze)           5          (Default from reset)  
*   01           8 (Idle)           8  
*   10           11                 11 (Doze, Idle) 
*   11           84 (Boost)         84 (Boost)
*****************************************************************************/           
#define ABEL_XTAL_BIAS_CURRENT 0x40 /* LSB  */

/*****************************************************************************
* Register 0x0A, bit (5:3)
* Chip rate
* Setting       AbelX.X
* ---------    ------------
*   0x00         Default from reset
*****************************************************************************/           
#define ABEL_CHIP_RATE 0x00 /* LSB  */


/*****************************************************************************
* Register 0x0A, bit (2:0)
* CLKO rate - selects the clock frequency of the CLKO out pin
* Setting       AbelX.X
* ---------    ------------
*   000          16MHz
*   001          8MHz
*   010          4MHz
*   011          2MHz
*   100          1MHz
*   101          62,5kHz
*   110          31,25kHz (default from reset)
*   111          15,625kHz
*****************************************************************************/           
#define ABEL_CLKO_FREQ 0x05 /* LSB  */

/*****************************************************************************
******************************************************************************
* Public type definitions
******************************************************************************
*****************************************************************************/
/* This is the NV RAM initializer layout.DO NOT USE THIS TYPE WHEN
     READING/WRITING DATA */

typedef struct InitNvramStruct_tag  {
	/* Missing version strings  */
	_CONST uint8_t Target_Version[48];
	_CONST uint8_t FreeLoader_Firmware_Version[52];
	_CONST uint16_t NV_RAM_Version;
	_CONST uint8_t MCU_Manufacture;
	_CONST uint8_t MCU_Version;
	_CONST uint8_t Bus_Frequency_In_MHz;
	_CONST uint16_t Abel_Clock_Out_Setting;
	_CONST uint16_t Abel_HF_Calibration;
	_CONST uint8_t NV_ICGC1;
	_CONST uint8_t NV_ICGC2;
	_CONST uint8_t NV_ICGFLTU;
	_CONST uint8_t NV_ICGFLTL;
	_CONST uint8_t NV_SCI1BDH;
	_CONST uint8_t NV_SCI1BDL;
	_CONST uint8_t MAC_Address[8];
	_CONST uint8_t ChannelSelect;
	_CONST uint8_t SleepModeEnable;
	_CONST uint8_t HWName_Revision[20];
	_CONST uint8_t SerialNumber[10];
	_CONST uint16_t ProductionSite;
	_CONST uint8_t CountryCode;
	_CONST uint8_t ProductionWeekCode;
	_CONST uint8_t ProductionYearCode;
	_CONST uint8_t defaultPowerLevel;
	_CONST uint8_t *paPowerLevelLimits;
	_CONST uint8_t useDualAntenna;
	_CONST uint8_t Reserved[4];
  _CONST uint8_t Application_Section[155];
	_CONST uint8_t SystemFlag; /*   Must not be change*/
	}InitNvramStruct_t;



/* This is the NV RAM layout. The layout covers a whole physical flash sector
   (512 bytes) in HCS08. The NV RAM data while be copied to another physical
   sector when updated. */
typedef struct NvramStruct_tag  {
	_CONST uint8_t Freescale_Copyright[54];
	_CONST uint8_t Firmware_Database_Label[40];
	_CONST uint8_t MAC_Version[47];
	_CONST uint8_t PHY_Version[47];
	_CONST uint8_t Target_Version[48];
	_CONST uint8_t FreeLoader_Firmware_Version[52];
	_CONST uint16_t NV_RAM_Version;
	_CONST uint8_t MCU_Manufacture;
	_CONST uint8_t MCU_Version;
	_CONST uint8_t Bus_Frequency_In_MHz;
	_CONST uint16_t Abel_Clock_Out_Setting;
	_CONST uint16_t Abel_HF_Calibration;
	_CONST uint8_t NV_ICGC1;
	_CONST uint8_t NV_ICGC2;
	_CONST uint8_t NV_ICGFLTU;
	_CONST uint8_t NV_ICGFLTL;
	_CONST uint8_t NV_SCI1BDH;
	_CONST uint8_t NV_SCI1BDL;
	_CONST uint8_t MAC_Address[8];
	_CONST uint8_t ChannelSelect;
	_CONST uint8_t SleepModeEnable;
	_CONST uint8_t HWName_Revision[18];
	_CONST uint8_t PA_Level[2];
	_CONST uint8_t SerialNumber[10];
	_CONST uint16_t ProductionSite;
	_CONST uint8_t CountryCode;
	_CONST uint8_t ProductionWeekCode;
	_CONST uint8_t ProductionYearCode;
	_CONST uint8_t defaultPowerLevel;
	_CONST uint8_t *paPowerLevelLimits;
	_CONST uint8_t useDualAntenna;
	_CONST uint8_t Reserved[4];
	_CONST uint8_t Application_Section[155];
	_CONST uint8_t SystemFlag; /* Must not be changed  */
} NvramStruct_t;            

typedef struct NvramIdentificationStruct_tag {
	_CONST uint8_t Version;
	_CONST uint8_t aString[4];  /* Sector Name */
	_CONST uint8_t SystemFlag;
}NvramIdentificationStruct_t;

typedef struct NvramSectorStruct_tag {
	_CONST uint8_t aData[506];
	_CONST uint8_t Version;
	_CONST uint8_t aString[4];  /* Sector Name */
	_CONST uint8_t SystemFlag;
}NvramSectorStruct_t;

/*****************************************************************************
******************************************************************************
* Public memory declarations
******************************************************************************
*****************************************************************************/

#pragma PLACE_CONST_SEG(BOOTLOADER_MAC_NV_DATA0)
  extern const uint8_t Freescale_Copyright[54]; /* Defined in MacMain.c */
  extern const uint8_t Firmware_Database_Label[40]; /* Defined in MacMain.c */
  extern const uint8_t MAC_Version[47]; /* Defined in MacMain.c */
#pragma RESTORE_CONST_SEG

#pragma PLACE_CONST_SEG(BOOTLOADER_PHY_NV_DATA0)
  extern const uint8_t PHY_Version[47]; /* Defined in PhyMain.c */
#pragma RESTORE_CONST_SEG


#pragma PLACE_CONST_SEG(BOOTLOADER_APP_NV_DATA0)
  extern volatile const InitNvramStruct_t mNvramMac; /* Initialized with
                                       default values for MAC sector  */
#pragma RESTORE_CONST_SEG


#pragma PLACE_DATA_SEG(NVM_SCRATCHPAD_POINTER)
  extern volatile void *gpScratchPadNvram; /* pointer to NV Scratchpad Data */
#pragma RESTORE_DATA_SEG

#pragma PLACE_DATA_SEG(MAC_NV_RAM_POINTER)
  extern volatile NvramStruct_t *gpMacNvram; /* A pointer to NV Data,
                       variable did not changed to keep MAC compatibility.  */
#pragma RESTORE_DATA_SEG

#pragma PLACE_CONST_SEG(NVM_SCRATCHPAD_DATA0)
  extern volatile const uint8_t gScratchPadNvram[512];
#pragma RESTORE_CONST_SEG

#pragma PLACE_DATA_SEG( ZS_NV_RAM_POINTER )
  extern volatile NvramSectorStruct_t * gapBeeStackNvram[ gNumOfZigBeeSectors_c ]; 
#pragma RESTORE_DATA_SEG


#pragma PLACE_CONST_SEG(NVM_ZIGBEE_DATA1)
  extern volatile const uint8_t gZS2Nvram[ gNVMDataPerSector_c ];
#pragma RESTORE_CONST_SEG  

#pragma PLACE_CONST_SEG(NVM_ZIGBEE_DATA0_INIT)
extern volatile const NvramIdentificationStruct_t gNvramZS1;
#pragma RESTORE_CONST_SEG

#pragma PLACE_CONST_SEG(NVM_ZIGBEE_DATA1_INIT)
extern volatile const NvramIdentificationStruct_t gNvramZS2;
#pragma RESTORE_CONST_SEG

extern void NV_Data_Init(void);
/************************************************************************************
* Set the NVM write operation semaphore.
*
* This function will set the NVM write operation semaphore so that the idle task wont
* do a NVM write operation unless this is released by calling 
* NVM_ClearCriticalNVMSection.
*
* Interface assumptions:
*   None
*   
* Return value:
*   None
* 
* Revision history:
*   date      Author    Comments
*   ------    ------    --------
*   230606    SP        Created
* 
************************************************************************************/

void NVM_SetCriticalNVMSection(void);

/************************************************************************************
* Release the NVM write operation semaphore.
*
* This function will release the NVM write operation semaphore so that the idle task 
* can do a NVM write operation.
*  
* Interface assumptions:
*   None
*   
* Return value:
*   None
* 
* Revision history:
*   date      Author    Comments
*   ------    ------    --------
*   230606    SP        Created
* 
************************************************************************************/

void NVM_ClearCriticalNVMSection(void);

#endif _NV_DATA_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -