📄 spl78k0_kx2.h
字号:
/************************************************************************************/
/* */
/* File: spl78k0_kx2.h */
/* Project: Selfprogramming application note, MF2 single voltage flash */
/* Device: 78k0/Kx2 */
/* Version: 1v06 */
/* Date: 12.09.2006 09:29 */
/* */
/* Copyright: (c)2004-2006 by NEC Electronics (Europe) GmbH. All rights reserved. */
/* */
/* Description: basic type definitions used in the SelfLib */
/* */
/* Environment: IAR environment for 78K0 (version V3.xx and V4.xx) */
/* */
/************************************************************************************/
#ifndef __SPL78K0_KX2_H_INCLUDED
#define __SPL78K0_KX2_H_INCLUDED
// include files list
// -------------------
#include "spl78k0_types.h" // NEC-EE
// compiler version specific declarations
#if(__VER__ >= 400)
#define __CODE_MODEL_PREFIX __non_banked
#else
#define __CODE_MODEL_PREFIX non_banked
#endif
// constant definitions
// ------------------------------------
// empty
// global function prototypes
// -------------------------------------
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: initialization of selfprogramming environment
// Input: data_buffer_pu08 - pointer to a data buffer of N...256 bytes
// (used for data exchange between firmware and application)
// Output: -
// Return: -
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX void SelfLib_Init(u08* data_buffer_pu08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: checks the voltage level (high or low) at FLMD0 pin
// Input: -
// Output: -
// Returned: u08, status_code
// = 0x00(STS_NO_ERROR), normal and means FLMD0=HIGH
// = 0x01(STS_ERROR), error, FLMD0=LOW
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_ModeCheck(void);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: checks if specified block is blank
// Input: block_u08 - block number has to be checked
// Output: -
// Returned: u08, status_code
// = 0x00(STS_NO_ERROR), normal and means "block is blank"
// = 0x05(STS_PARAMETER_ERROR), parameter error
// = 0x1B(STS_MRG11_ERROR), blank-check error, means "block not blank"
// = 0x1F(STS_INTERRUPTED), blank-check interrupted by user interrupt
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_BlankCheck(u08 block_u08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: erase specified block
// Input: block_u08 - block number has to be erase
// Output: -
// Returned: u08, status_code
// = 0x00(STS_NO_ERROR), normal and means "block erased successfully"
// = 0x05(STS_PARAMETER_ERROR), parameter error
// = 0x10(STS_PROTECTION_ERROR), tried to erase protected area
// = 0x1A(STS_MRG10_ERROR), erase error, retry up to max. 255 times
// = 0x1F(STS_INTERRUPTED), erasing interrupted by user interrupt
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_Erase(u08 block_u08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: performs internal verify on specified block
// Input: block_u08 - block number has to be verified
// Output: -
// Returned: u08, status_code
// = 0x00(STS_NO_ERROR), normal and means "block is verified"
// = 0x05(STS_PARAMETER_ERROR), parameter error
// = 0x1B(STS_MRG11_ERROR), internal verify error
// = 0x1F(STS_INTERRUPTED), verify interrupted by user interrupt
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_Verify(u08 block_u08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: writes N words from the data buffer into flash
// Input: s_address_u32 - starting flash address the data has to be written
// See Condition 2) please.
// my_wordcount_u08 - number of words (4 bytes) has to be written
// Output: -
// Condition: 1) (s_address_u32 MOD 4 == 0)
// 2) most significant byte (MSB) of s_address_u32 has to be 0x00.
// Means: 0x00abcdef 24 bit flash address allowed
// 3) (word_count_u08 <= sizeof(data buffer)) NOT CHECKED BY FIRMWARE !!!!!
// Changed: -
// Returned: u08, status code
// = 0x00(STS_NO_ERROR), normal
// = 0x05(STS_PARAMETER_ERROR), parameter error
// = 0x10(STS_PROTECTION_ERROR), protection error
// = 0x1C(STS_WRITE_ERROR), write error
// = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_Write(u32 s_address_u32, u08 word_count_u08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: writes N words from the data buffer into flash
// Before "writing" a N-word blankcheck is performed.
// After "writing" a N-Word internal verify is performed.
// Input: s_address_u32 - starting destination address has to be written
// my_wordcount_u08 - number of words (4 bytes) has to be written
// Output: -
// Condition: 1) (s_address_u32 MOD 4 == 0)
// 2) (word_count_u08 <= sizeof(data buffer)) NOT CHECKED BY FIRMWARE !!!!!
// Changed: -
// Returned: u08, status code
// = 0x00(STS_NO_ERROR), normal
// = 0x05(STS_PARAMETER_ERROR), parameter error
// = 0x10(STS_PROTECTION_ERROR), protection error
// = 0x1C(STS_WRITE_ERROR), write error
// = 0x1D(STS_EEPWRITE_VERIFY_ERROR), verify error
// = 0x1E(STS_EEPWRITE_BLANK_ERROR), blankcheck error
// = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_EepWrite(u32 s_address_u32, u08 word_count_u08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: reads the security information
// Input: destination_pu08 - destination address of the security info
// The format of the security info is: "unsigned char"
//
// Format of the security info:
// bit_0 = 0 -> chip erase command disabled, otherwise enabled
// bit_1 = 0 -> block erase command disabled, otherwise enabled
// bit_2 = 0 -> write command disabled, otherwise enabled
// bit_4 = 0 -> boot-area re-programming disabled, otherwise enabled
// other bits = 1
// Output: -
// Changed: content of the data_buffer
// Returned: u08, status code
// = 0x00(STS_NO_ERROR), normal
// = 0x05(STS_PARAMETER_ERROR), parameter error
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_GetInfo_Security(u08 *destination_pu08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: read the boot flag i
// Input: destination_pu08 - destination address of the bootflag info
// The format of the boot-flag info is: "unsigned char"
// The value of the boot info is 0x00 for cluster 0 and 0x01 for cluster 1.
// Output: -
// Changed: content of the data_buffer
// Returned: u08, status code
// = 0x00(STS_NO_ERROR), normal
// = 0x05(STS_PARAMETER_ERROR), parameter error
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_GetInfo_BootCluster(u08 *destination_pu08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: puts the last address of the specified block into *destination_pu32
// Input: *destination_pu32 - destination where the last-block-address
// should be stored
// block_u08 - block number of the last address is needed
// Changed: -
// Returned: u08, status code
// = 0x00(STS_NO_ERROR), normal
// = 0x05(STS_PARAMETER_ERROR), parameter error
// ---------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_GetInfo_BlockEndAddr(u32 *destination_pu32, u08 block_u08);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: inverts the current value of the boot flag inside the extra area
//
// CAUTION !!!!
// 1) mask all interrupts before using this command (DI is not enough)
// 2) After RESET the "opposite" boot-cluster is activated.
// Therefore, take care for valid boot-loader inside
// before using that command.
// Input: -
// Output: -
// Returned: u08, status code
// = 0x00(STS_NO_ERROR), normal
// = 0x05(STS_PARAMETER_ERROR), parameter error
// = 0x10(STS_PROTECTION_ERROR), protection error
// = 0x1A(STS_MRG10_ERROR), erase error
// = 0x1B(STS_MRG11_ERROR), internal verify error
// = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_SetInfo_SwapBootCluster(void);
// -----------------------------------------------------------------------------
// Block type: selflib command function
// -----------------------------------------------------------------------------
// Purpose: sets specified security flag by dedicated command-function.
//
// There are following security levels:
// a) chip-erase protection (cannot be reset by programmer !!!)
// b) block-erase protection (can be reset by programmer)
// c) write protection (can be reset by programmer)
// d) boot-cluster protection (cannot be reset by programmer !!!)
//
// CAUTION !!!!
// 1) mask all interrupts before using this commands (DI is not enough)
// 2) each security flag can be written by the application only once
//
// Input: -
// Output: -
// Returned: u08, status code
// = 0x00(STS_NO_ERROR), normal
// = 0x05(STS_PARAMETER_ERROR), parameter error
// = 0x10(STS_PROTECTION_ERROR), protection error
// = 0x1A(STS_MRG10_ERROR), erase error
// = 0x1B(STS_MRG11_ERROR), internal verify error
// = 0x1F(STS_INTERRUPTED), write interrupted by user interrupt
// -----------------------------------------------------------------------------
extern __CODE_MODEL_PREFIX u08 SelfLib_SetInfo_ChipEraseProtection(void);
extern __CODE_MODEL_PREFIX u08 SelfLib_SetInfo_BlockEraseProtection(void);
extern __CODE_MODEL_PREFIX u08 SelfLib_SetInfo_WriteProtection(void);
extern __CODE_MODEL_PREFIX u08 SelfLib_SetInfo_BootClusterProtection(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -