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

📄 main.c

📁 T89C51CC01 uart BOOTLOAD
💻 C
字号:
/*C*****************************************************************************
* FILE_NAME         : main.c                                             
*----------------------------------------------------------------------------
* FILE_CREATED_BY   : BERTHY JS                                             
* FILE_CREATION_DATE: 4/05/00                                              
*----------------------------------------------------------------------------
* FILE_PURPOSE:    
*
******************************************************************************/
/*_____ I N C L U D E - F I L E S ____________________________________________*/

#include "compiler.h"
#include "config.h"
#include "schedule.h"
#include "bootloader.h"

/*_____ G L O B A L S ________________________________________________________*/

extern void api_task(void);


extern Uchar  api_command;
extern Uchar  api_value;
extern Uchar  api_dpl;
extern Uchar  api_dph;


/*- Flag Declaration -*/

bdata Uchar flag;
Sbit( flag_7, flag, 7);	  
Sbit( flag_6, flag, 6);  
Sbit( flag_5, flag, 5);  
Sbit( flag_4, flag, 4);  
Sbit( flag_3, flag, 3);  
Sbit( flag_2, flag, 2);  
Sbit( flag_1, flag, 1);  
Sbit( flag_0, flag, 0); 
 




/*_____ P R I V A T E - F U N C T I O N S - D E C L A R A T I O N ____________*/
void boot_process (void);


/*_____ L O C A L S __________________________________________________________*/




/*F**************************************************************************
* FUNCTION_NAME: main                                             
*-------------------------------------------------------------------------
* FUNCTION_AUTHOR: BERTHY J.S.                                              
* FUNCTION_DATE  : 4/05/00                                                 
*----------------------------------------------------------------------------
* FUNCTION_PURPOSE:                          
* FUNCTION_INPUTS : void
* FUNCTION_OUTPUTS: void                                                                                                                 
******************************************************************************/
void main (void)
{
  CKCON = 0xFE; /* mode X1 */

	flag = 0;

#ifndef DEBUG 
  boot_process();
#endif

  schedule_init();                           
  
  while(1)
  {
    schedule();
  }

}

/*F**************************************************************************
* FUNCTION_NAME: boot_from_appli                                           
*-------------------------------------------------------------------------
* FUNCTION_AUTHOR: BERTHY J.S.                                              
* FUNCTION_DATE  : 4/05/00                                                 
*----------------------------------------------------------------------------
* FUNCTION_PURPOSE: This function is the entry point when the bootloader is
*               started from the application.
*                   the bootloader keep the can bit config                          
* FUNCTION_INPUTS : void
* FUNCTION_OUTPUTS: void                                                                                                                 
******************************************************************************/
void boot_from_appli (void)
{  
	SP = 0x39;
	flag = 0;

	f_start_from_appli = 1;
	f_communication_open = 1;
 	f_frame_to_send = 1;
  can_tx[0] = BOOTLOADER_VERSION;
  can_tx[1] = f_communication_open;
  can_ctrl  = 2;
  
	schedule_init();                           

  while(1)
  {
    schedule();
  }

}


/*F**************************************************************************
* FUNCTION_NAME: USER_CALL                                           
*-------------------------------------------------------------------------
* FUNCTION_AUTHOR: BERTHY J.S.                                              
* FUNCTION_DATE  : 4/05/00                                                 
*----------------------------------------------------------------------------
* FUNCTION_PURPOSE: This function is the entry point for called API from
*                 application.
*                   Before called this function, the api must be select with 
*                 R1 and parameters passed by DPTR;                           
* FUNCTION_INPUTS : void
* FUNCTION_OUTPUTS: void                                                                                                                 
******************************************************************************/
void USER_CALL (void)
{  
  do
  {
    api_task(); 
  }while( api_command != WAIT_COMMAND);
}

/*F**************************************************************************
* FUNCTION_NAME: boot_process                                           
*-------------------------------------------------------------------------
* FUNCTION_AUTHOR: BERTHY J.S.                                              
* FUNCTION_DATE  : 4/05/00                                                 
*----------------------------------------------------------------------------
* FUNCTION_PURPOSE: This function allows to execute the Default bootloader,
* The user bootloader or the application.                           
* FUNCTION_INPUTS : void
* FUNCTION_OUTPUTS: void                                                                                                                 
******************************************************************************/
void boot_process (void)
{  
	Uchar sbv_copy;

	if (FCON == 0xF0)	
	{
	  DPL = SBV_ADD; 
  	API_RD_XAF();
  	sbv_copy = ACC;
		if (sbv_copy <= 0x7F)
		{
			SP 	= 0x07;	
			DPL = 0x00;
			DPH = sbv_copy;
			ASM_JMP_DPTR();
		}  
	}

}






⌨️ 快捷键说明

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