mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
test for py script from uart is ok
This commit is contained in:
parent
04d292db3c
commit
7b816b1546
@ -313,7 +313,7 @@
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>6</Optim>
|
||||
<Optim>2</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
@ -332,7 +332,7 @@
|
||||
<v6LangP>3</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>1</v6Lto>
|
||||
<v6Lto>0</v6Lto>
|
||||
<v6WtE>0</v6WtE>
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
|
@ -47,8 +47,8 @@
|
||||
#define FLASH_SCRIPT_START_ADDR (FLASH_BASE + ((FLASH_PAGE_NB - 1) * FLASH_PAGE_SIZE))
|
||||
#define FLASH_SCRIPT_END_ADDR (FLASH_BASE + FLASH_SIZE - 1)
|
||||
|
||||
#define FLASH_PIKA_ASM_START_ADDR (FLASH_BASE + ((FLASH_PAGE_NB - 2) * FLASH_PAGE_SIZE))
|
||||
#define FLASH_PIKA_ASM_END_ADDR (FLASH_BASE + ((FLASH_PAGE_NB - 1) * FLASH_PAGE_SIZE))
|
||||
#define FLASH_PIKA_ASM_START_ADDR FLASH_SCRIPT_START_ADDR
|
||||
#define FLASH_PIKA_ASM_END_ADDR FLASH_SCRIPT_END_ADDR
|
||||
|
||||
uint32_t GetPage(uint32_t Addr);
|
||||
#define DATA_64 ((uint64_t)0x1234567812345678)
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "STM32_common.h"
|
||||
#include "pikaScript.h"
|
||||
#include "stdbool.h"
|
||||
#include "pikaVM.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@ -98,16 +99,25 @@ int main(void) {
|
||||
|
||||
char* code = (char*)FLASH_SCRIPT_START_ADDR;
|
||||
uint16_t codeOffset = 0;
|
||||
if (code[0] == 'i') {
|
||||
if (code[0] != 0xFF) {
|
||||
/* boot from flash */
|
||||
pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
obj_run(pikaMain, "uart = STM32.UART()");
|
||||
obj_run(pikaMain, "uart.init()");
|
||||
obj_run(pikaMain, "uart.setId(1)");
|
||||
obj_run(pikaMain, "uart.setBaudRate(115200)");
|
||||
obj_run(pikaMain, "uart.setBaudRat e(115200)");
|
||||
obj_run(pikaMain, "uart.enable()");
|
||||
obj_run(pikaMain, "print('[info]: boot from flash.')");
|
||||
obj_run(pikaMain, code);
|
||||
obj_deinit(pikaMain);
|
||||
pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
if(code[0] == 'i'){
|
||||
printf("[info]: boot from Script.\r\n");
|
||||
obj_run(pikaMain, code);
|
||||
}
|
||||
if(code[0] == 'B'){
|
||||
printf("[info]: boot from Pika Asm.\r\n");
|
||||
pikaVM_runAsm(pikaMain, code);
|
||||
}
|
||||
} else {
|
||||
/* boot from firmware */
|
||||
pikaMain = pikaScriptInit();
|
||||
|
@ -144,6 +144,7 @@ static int32_t getPyLineBlockDeepth(char* line) {
|
||||
AST* pikaParseLine(char* line, Stack* blockStack) {
|
||||
AST* ast = New_queueObj();
|
||||
Args* buffs = New_strBuff();
|
||||
line = strsDeleteChar(buffs, line, '\r');
|
||||
uint8_t blockDeepth = getPyLineBlockDeepth(line);
|
||||
uint8_t blockDeepthLast = blockDeepth;
|
||||
if (NULL != blockStack) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user