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

📄 nf_loader.h

📁 mp3播放器
💻 H
字号:
//! @file nf_loader.h,v
//!
//! Copyright (c) 2004 Atmel.
//!
//! Please read file license.txt for copyright notice.
//!
//! @brief This file is the header file for the management of specific zone of NF
//! This specific zone containt the firmwares, codecs, fonts, displays.
//!
//! @version 1.35 snd3-refd1-1_9_5 $Id: nf_loader.h,v 1.35 2007/07/24 09:37:35 sguyon Exp $
//!
//! @todo
//! @bug

#ifndef _NF_LOADER_H_
#define _NF_LOADER_H_

//_____ I N C L U D E S ____________________________________________________

#include "lib_mcu\nfc\nfc_drv.h"
#include "conf\conf_access.h"
#include "conf\conf_update.h"


//_____ M A C R O S ________________________________________________________

//_____ A D V A N C E   U P D A T E   C O N F I G U R A T I O N ____________

//! --- FW zone copy ---
//! Authorize to do a copy of the FW zone (and check CRC of all FW at beginning)
//! Values: - ENABLE
//!         - DISABLE
#define UPDATE_DO_FW_COPY                 DISABLE

//! --- Codec zone copy ---
//! Authorize to do a copy of the Codec zone (and check CRC of all Codec at beginning)
//! Values: - ENABLE
//!         - DISABLE
#define UPDATE_DO_CODEC_COPY              DISABLE


#undef _GLOBEXT_
#if (defined _nf_loader_c_)
   #define _GLOBEXT_
#else                                        
   #define _GLOBEXT_ extern
#endif


//_____ D E F I N I T I O N S ______________________________________________

// Definition of labels from ones defined in "nfc_drv.h"
#define  NF_NB_BYTE_PER_PAGE           (1<<(NF_SHIFT_PAGE_BYTE))
#define  NF_MSB_NB_BYTE_PER_PAGE       (NF_NB_BYTE_PER_PAGE>>8)
#define  NF_LSB_NB_BYTE_PER_PAGE       (NF_NB_BYTE_PER_PAGE & 0xFF)
#define  NF_MASK_NB_BYTE_PER_PAGE      (NF_NB_BYTE_PER_PAGE-1)
#define  NF_MSB_MASK_NB_BYTE_PER_PAGE  (NF_MSB_NB_BYTE_PER_PAGE-1)
#define  NF_LSB_MASK_NB_BYTE_PER_PAGE  (NF_LSB_NB_BYTE_PER_PAGE-1)


#define  NF_NB_SECTOR_PER_PAGE   (NF_NB_BYTE_PER_PAGE /512)
#define  NF_NB_PAGE_PER_BLOCK    (1<<(NF_SHIFT_BLOCK_PAGE))



//_____ Z O N E   D E F I N I T I O N S ____________________________________

#define  NB_ZONES     6 
// ZONE_XX must be just befor ZONE_XX_COPY. 
// Keep ZONE_FIRMWARE & ZONE_FIRMWARE_COPY first!!!
typedef enum { ZONE_FIRMWARE, ZONE_FIRMWARE_COPY, ZONE_CODEC, ZONE_CODEC_COPY, ZONE_PICTURE, ZONE_FONT, ZONE_NO_ZONE} Zone;

//_____ M O D U L E   D E F I N I T I O N S ________________________________

// Definitions of zone module IDs
//    Module IDs of the codec zone
#define  CODEC_PLAY_FIRST  (0)
#define  CODEC_MP3         (0)
#define  CODEC_WMA         (1)
#define  CODEC_WAV         (2)
#define  CODEC_MTV         (3)
#define  CODEC_MP2         (4)
#define  CODEC_WMA_2       (5)
#define  CODEC_PLAY_MAX    (6)

#define  CODEC_REC_FIRST   (10)
#define  CODEC_REC_G726    (10)
#define  CODEC_REC_MAX     (11)

#define  CODEC_VIEW_FIRST  (20)
#define  CODEC_JPG         (20)
#define  CODEC_BMP         (21)
#define  CODEC_VIEW_MAX    (22)

#define  CODEC_ADC         (30)

#define  CODEC_CIPHER      (50)

//    Module IDs of the picture zone
#define  PICTURE_DEFAULT   (0)

//    Module IDs of the font zone
#define  FONT_NORMAL       (0)
#define  FONT_TBL_GB2312   (20)
#define  FONT_TBL_B5       (21)


//_____ P A T T E R N   D E F I N I T I O N S ______________________________

// Definitions of a unique pattern for each zone
// in order to detect its location in one of the NF flash blocks

#define  SZ_PATTERN_IN_BYTE       ( 8 )                            // Size in bytes

#define  PATTERN_FIRMWARE_HEAD   0xA5,0x5A     // The first 16-bit of the 64-bit pattern value

#define  PATTERN_FIRMWARE        PATTERN_FIRMWARE_HEAD

#define  PATTERN_CODEC           0x37,0x73,0x37,0x73,0x37,0x73,0x37,0x73   // Big-endian 64-bit value
#define  PATTERN_PICTURE         0xB4,0x4B,0xB4,0x4B,0xB4,0x4B,0xB4,0x4B   // Big-endian 64-bit value
#define  PATTERN_FONT            0xC3,0x3C,0xC3,0x3C,0xC3,0x3C,0xC3,0x3C   // Big-endian 64-bit value


//_____ M O D U L E   H E A D E R   D E F I N I T I O N S __________________

#define  MAX_MODULE_PER_ZONE        20
#if ( 9 == G_SHIFT_PAGE_BYTE)
#  define  MAX_NB_FRAGMENTS         5  // With a 512 bytes per page memory 
#else
#  define  MAX_NB_FRAGMENTS         3  // With a 2048 bytes per page memory
#endif

#define  UNFOUND_PATTERN            0xFFFFFFFF



//_____ D E F I N I T I O N S ______________________________________________

// Segment structure
typedef struct
{
   U16 nb_pages;
   U8  device_number;
   U16 block_addr;
} Fragment;

// Structure of the module header 
typedef struct
{
   Fragment frag[MAX_NB_FRAGMENTS];
#if ((FUNC_UPDATE == ENABLE) && (UPDATE_DO_FW_COPY == ENABLE))   // FW update & FW copy is implemented   
   U8       option;
#endif
   U32      true_size;     // size of the module
   U32      data_amount;   // same as true_size but aligned up on 512 bytes boundary  
   U16      CRC;
   U8       nb_frag;
   U8       start_page;
} Module_struct;

//#define MAPNF_FW_OPT_DFC_LOAD    (1<<0)   // module autorizes the loading by DFC
//#define MAPNF_FW_OPT_BOOSTBOOT   (1<<1)   // module autorizes the boost boot
#define MAPNF_FW_OPT_DFC_CRC     (1<<2)   // CRC is computed by DFC
//#define MAPNF_FW_OPT_CRYPT       (1<<3)   // module is crypted


// Structure for handling the module data
typedef struct
{
   U8  i_frag;          // idx of the current fragment read
   U32 page_addr;       // current page address
   U8  nb_pages;        // nb of pages remaining before reaching the end of the current fragment
   U8  nb_frag;         // nb of fragments used in the definition of the current module 
                        // (implemented here just for a debug information)
   U16 offset;          // offset in the start read page
   U8  device_number;   // current device number
} Module_hdl_struct;


//_____ M A C R O S ________________________________________________________

// Load the handle with parameters of the current fragment
#define Nfloader_load_hdl()                                                                           \
{                                                                                                     \
   s_mod_hdl.device_number =       s_module.frag[s_mod_hdl.i_frag].device_number;                     \
   s_mod_hdl.page_addr     = (U32) s_module.frag[s_mod_hdl.i_frag].block_addr * NF_NB_PAGE_PER_BLOCK; \
   s_mod_hdl.nb_pages      =       s_module.frag[s_mod_hdl.i_frag].nb_pages;                          \
}

//_____ D E C L A R A T I O N S ____________________________________________

void  nfloader_init                             ( void );
U8    nfloader_init_load_module                 ( U8, Zone );
U8    nfloader_compute_physic_addr              ( U32  ); 
void  nfloader_compute_physic_addr_0            ( void );
U8    nfloader_get_data_and_fetch_next_one      ( void );
U8    nfloader_get_module_sector_number         ( void );
#if 0                                           
U16   nfloader_get_module_size                  ( void );
#endif
#if (CODE_BANKING == ENABLE)
U8    nfloader_get_sector_number                ( U16  );
#  if (BANK_DECIPHER == ENABLE)
U16   nfloader_get_remaining_size               ( U16  );
#  endif
#endif
void  nfloader_init_resume_module               ( void );
void  nfloader_resume_module                    ( void );
void  nfloader_read_version                     ( U8 _MEM_TYPE_SLOW_ *buffer );
U16   nfloader_get_unaligned_bytes              ( void );
void  nfloader_open_next_page                   ( void );
void  nfloader_open_page_for_reading_via_register(void );



#endif  // _NF_LOADER_H_

⌨️ 快捷键说明

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