📄 main.c
字号:
////////////////////////////////////////////////////////////////
//
// S C R I P T H E R M
// A SCRIPTABLE THERMOMETER
//
// entry of the National Semiconductor COP8FLASH Design Contest
// submitted by Alberto Ricci Bitti (C) 2001
// a.riccibitti@ra.nettuno.it
//
//--------------------------------------------------------------
// FOR A BETTER VIEW SET TAB SIZE=4, INDENT SIZE=4
//--------------------------------------------------------------
// FILE : main.c
// PURPOSE: the master module. Initializes the system
// and runs the script interpreter.
// In case of errors, calls program() to
// invoke the editor
//
// IMPORTANT: use the linker file custom_LNK8LGL1.XCL
//
////////////////////////////////////////////////////////////////
#include <incop8.h>
#include "types.h"
#include "lcd.h"
#include "timer_io_adc.h"
#include "serial.h"
#include "memory.h"
#include "edit.h"
#include "errors.h"
#include "tokenizer.h"
#include "variables.h"
#include "script.h"
jmp_buf error_mark;
volatile flags_t flags = {0,0,0,0,0};
// Invokes the editor. The program must be copied from FLASH to RAM
// prior to editor launch, and from RAM back to FLASH when the editor quits
// If the "debug" flag is set, the program is precompiled replacing
// token strings with token codes
void program(void)
{
LCD_puts("\nPROGRAM ENDED");
while (! flags.program)
{ /*loop intentionally void*/ };
LCD_clear_text(); LCD_clear_graphics();
if (flags.clear)
{ LCD_puts("Clearing...");
clear_ram();
token_address = 0;
}
else
{ LCD_puts("Loading...");
copy_flash_to_ram();
};
edit_program(token_address);
LCD_clear_text(); LCD_puts("Saving...");
copy_ram_to_flash();
if (flags.debug)
{ zip_tokens();
LCD_puts("\nCompiling...");
copy_ram_to_flash();
};
prepare_to_run();
LCD_clear_text();
}
__c_task main(void)
{
com_initialize();
LCD_initialize();
LCD_locate(0,0);
timer_io_adc_initialize();
therm_initialize();
__enable_interrupt();
prepare_to_run();
//setjmp entry point in case of errors
if( error_occurred() ) flags.running = FALSE;
main_loop:
if (! flags.running) program();
if (flags.update_therm) therm_update();
exec_command();
goto main_loop;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -