📄 bl78k0_kx2_help_fkt.c
字号:
//==============================================================================
// PROJECT = Bootloader
// MODULE = bl78k0_kx2_help_fkt.c
// SHORT DESC. = Help functions
// DEVICE = 78K0/Kx2
// VERSION = 1.0
// DATE = 05.12.2006
// LAST CHANGE =
// =============================================================================
// By: NEC Electronics (Europe) GmbH
// Arcadiastrasse 10
// D-40472 Duesseldorf
// =============================================================================
#include "bl78k0_kx2_help_fkt.h"
//*****************************************************************************
// extern global variables
//*****************************************************************************
extern __saddr u32 temp_u32;
extern __callt void sendString (u08 *ucpStr);
__saddr u16 crc;
//*****************************************************************************
// Function: calcCRC
// Parameter: u08 -> byte for crc calculating
// Return: void
// Description: Calculate CRC for give byte
// ATTENTION: The calcCRC must be called with 2 zero bytes after calculation!
//*****************************************************************************
__callt void calcCRC( u08 val)
{
for (u08 i = 0; i < 8; ++i)
{
temp_u32 = crc;
crc <<= 1;
if (val & 0x80)
crc |= 1 ;
if (temp_u32 & 0x8000)
crc ^= 0x1021;
val <<= 1;
}
}
//*****************************************************************************
// Function: resetCRC
// Parameter: none
// Return: void
// Description: Reset calculated CRC
//*****************************************************************************
__callt void resetCRC(void)
{
crc = 0; // reset CRC
}
//*****************************************************************************
// Function: resetCRC
// Parameter: none
// Return: void
// Description: Reset calculated CRC
//*****************************************************************************
__callt u16 getCRC(void)
{
return crc; // return CRC
}
//*****************************************************************************
// Function: getASCII
// Parameter: u08, 0000XXXXb
// Return: void
// Description: Reset calculated CRC
//*****************************************************************************
__callt u08 getASCII(u08 byte_nibble)
{
if( byte_nibble < 10 ) // is byte_nibble < 10
{
return ( byte_nibble | 0x30 ); // return byte|0x30
}
else
{
byte_nibble += 1; // increment, because A-F
return ( byte_nibble | 0x40 ); // return byte|0x40
}
}
//*****************************************************************************
// Function: rom_Read
// Parameter: u16 -> address where the content must be read
// Return: u08 -> content at the give address
// Description: This function read the content of the given address
//*****************************************************************************
__callt u08 rom_Read(u16 ROM_addr)
{
u08 buffer = 0;
u08 *ptr1;
ptr1 = (u08 *) ROM_addr;
buffer = *ptr1;
return buffer;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -