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

📄 bl78k0_kx2_main.c

📁 NEC upd78f0300的自编程序样例
💻 C
字号:
//==============================================================================
// PROJECT      = Bootloader
// MODULE       = bl78k0_kx2_main.c
// SHORT DESC.  = Main
// DEVICE       = 78K0/Kx2
// VERSION      = 1.0
// DATE         = 05.12.2006
// LAST CHANGE  =
// =============================================================================
// By:          NEC Electronics (Europe) GmbH
//              Arcadiastrasse 10
//              D-40472 Duesseldorf
// =============================================================================




#include "io78f0547_80.h"

#include <intrinsics.h>
#include "bl78k0_kx2_user.h"
#include "bl78k0_kx2_const.h"
#include "bl78k0_kx2_control.h"


//*****************************************************************************
// extern function prototype
//*****************************************************************************
extern void  SelfLib_Close(void);

//*****************************************************************************
// Option Byte// Watchdog-Timer on, max. time, can be stopped
//*****************************************************************************
#pragma location = "OPTBYTE"
__root const u08 opbyte[]={0x00,0x00,0x00,0x00,0x02};


//*****************************************************************************
// Module:   main
// Description: main module
//*****************************************************************************
void main(void)
{
  	__disable_interrupt();                  // disable all interrupts
  	u08 state_bootloader = 0;               // bootloader state
  	u08 state_update = 0;                   // update state

  	STOP_WATCHDOG;              // Int. low-speed osc. stopped, watchdog stopped

  	init_micro();                           // microcontroller initialization

    while(!SRIF6);


  	state_bootloader = BOOTLOADER_START;    // set bootl. state on start

  	while(1)
  	{
        {P5_bit.no0 = 1; PM5_bit.no0 = 0; }
        {P5_bit.no0 = 0; PM5_bit.no0 = 1; }
  	  	
        switch(state_bootloader)              // bootl. state?
  	  	{
  	  	  	case BOOTLOADER_START:              // bootl. start
  	  	  	  	state_bootloader = bootloader_start();
  	  	  	  	break;

  	  	  	case UPDATE:                        // update state!
  	  	  	  	state_update = executeUpdate();     // start update

  	  	  	  	if( state_update == APP_START )   // is app. start
  	  	  	  	{
  	  	  	  	  state_bootloader = APP_START;   // switch to app. start
  	  	  	  	  break;
  	  	  	  	}
  	  	  	  	else                              // error state
  	  	  	  	{
  	  	  	  	  exceptionHandler();             // handle exception
  	  	  	  	  resetAll();                     // reset bootloader modules
  	  	  	  	  state_bootloader = BOOTLOADER_START;  // bootl. state start
  	  	  	  	}
  	  	  	  	break;

  	  	  	case APP_START:                     // app. start state
  	  	  	  	SelfLib_Close();                  // close self lib environment
  	  	  	  	sendString( START_SOFT_TEXT );    // app. start message

  	  	  	  	asm("br 0x1010");                 // branch to application
  	  	}
  	}
}

⌨️ 快捷键说明

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