The basic decoding experiment based on STM32F1
1. Basic program is stored in file form
2. Program files stored in SD card
3, the explanation results are displayed on the LCD screen
Main function Section
int main (void)
{
U16 I,j;
Delay_init (72);//Delay initialization
Init_io ();
Glcd_init ();//Initialize LCD
back_color=0x001f;
Lcd_showstring (30,10, "Mini STM32 SD Card TEST");
Lcd_showstring (30,30,__date__);
Lcd_showstring (150,30,__time__);
Ffext_mount (0, &FS);
Ffext_read ("0:3.bas", Wbuff2, 1024x768, Fa_open_always | Fa_read);
back_color=0x001f;
point_color=0xf800;
Basic (WBUFF2);
while (1)
{
}
}
Basic Keyword Section
struct Commands/* Keyword lookup table */
{
Char command[20];
Char Tok;
}table[] ={/* command must be entered in lowercase */
"Print", print,
"Input", input,
"If", if,
"Then" and then,
"Goto", Goto,
' For ', for,
"Next", Next,
' To ', to,
"GoSub", GoSub,
"Return", Return,
"End", End,
"", End//ending of the Word table */
};
Executive Section
void Basic (Char *buf)
{
Char *p_buf;
/* Load the source file */
P_buf=buf;
if (setjmp (E_BUF)) exit (1); /* Initialize the long jump buffer */
Prog = P_buf;
Scan_labels (); /* Locate the label in the program */
FTOs = 0; /* Initialize the for stack index */
GTOs = 0; /* Initialize GoSub stack index */
Do
{
Token_type = Get_token ();
/* Check Assignment statement */
if (token_type==variable)
{
Putback (); /* Return the variable to the input stream */
Assignment (); /* Must be an assignment statement */
}
else/* is the command */
Switch (TOK)
{
Case PRINT:
Print ();
Break
Case GOTO:
Exec_goto ();
Break
Case IF:
Exec_if ();
Break
Case for:
Exec_for ();
Break
Case NEXT:
Next ();
Break
Case INPUT:
Input ();
Break
Case GOSUB:
GoSub ();
Break
Case RETURN:
Greturn ();
Break
Case END:
printf ("Run basic end!");
while (1);
Exit (0);
}
}while (tok! = finished);
}
//////////////////////////////////////////////////////////////////////////
Reference: Http://pan.baidu.com/s/1nt2y7O1
Test hardware: http://item.taobao.com/item.htm?spm=a1z10.5-c.w4002-2613737244.27.uf9NEY&id=43666799360
Basic decoding experiment based on STM32F1 VB Basic LCD display execution process and results