From 4e747a49ed5b665021ec5876a98d5ecf52bd88da Mon Sep 17 00:00:00 2001 From: lyon Date: Fri, 18 Mar 2022 00:02:43 +0800 Subject: [PATCH] update 030 to v1.5.0rc --- bsp/stm32g030c8/Booter/main.c | 28 ++--- bsp/stm32g030c8/Booter/pika_config.c | 38 +++---- bsp/stm32g030c8/MDK-ARM/stm32g030c8.uvprojx | 117 ++++++++++---------- bsp/stm32g030c8/pikascript/requestment.txt | 4 +- examples/GPIO/main.py | 1 + examples/PWM/main.py | 2 + examples/Task/main.py | 1 + 7 files changed, 94 insertions(+), 97 deletions(-) diff --git a/bsp/stm32g030c8/Booter/main.c b/bsp/stm32g030c8/Booter/main.c index a0ba05a98..16dae491a 100644 --- a/bsp/stm32g030c8/Booter/main.c +++ b/bsp/stm32g030c8/Booter/main.c @@ -102,29 +102,17 @@ int main(void) { /* boot from flash */ pikaMain = newRootObj("pikaMain", New_PikaMain); __pikaMain = pikaMain; + printf("[info]: boot from flash.\r\n"); if (code[0] == 'i') { - printf("[info]: compiling the python...\r\n"); - main_codeBuff = arg_setStr(NULL, "", code); - // obj_run(pikaMain, arg_getStr(main_codeBuff)); - Args* buffs = New_args(NULL); - Parser_multiLineToAsm(buffs, arg_getStr(main_codeBuff)); - NVIC_SystemReset(); - goto main_loop; - } - if (code[0] == 'B') { -// printf("==============[Pika ASM]==============\r\n"); -// for (int i = 0; i < strGetSize(code); i++) { -// if ('\n' == code[i]) { -// fputc('\r', (FILE*)!NULL); -// } -// fputc(code[i], (FILE*)!NULL); -// } -// printf("==============[Pika ASM]==============\r\n"); - printf("[info]: asm size: %d\r\n", strGetSize(code)); - printf("[info]: boot from Pika Asm.\r\n"); - pikaVM_runAsm(pikaMain, code); + obj_run(pikaMain, code); goto main_loop; } +// if (code[0] == 'B') { +// printf("[info]: asm size: %d\r\n", strGetSize(code)); +// printf("[info]: boot from Pika Asm.\r\n"); +// pikaVM_runAsm(pikaMain, code); +// goto main_loop; +// } } else { /* boot from firmware */ printf("[info]: boot from firmware.\r\n"); diff --git a/bsp/stm32g030c8/Booter/pika_config.c b/bsp/stm32g030c8/Booter/pika_config.c index dfd98a1ad..ada71d0a8 100644 --- a/bsp/stm32g030c8/Booter/pika_config.c +++ b/bsp/stm32g030c8/Booter/pika_config.c @@ -164,12 +164,12 @@ uint32_t flash_write_char(uint32_t bassAddr, return flash_addr; } -uint8_t __platform_Asm_is_to_flash(char* pyMultiLine) { - if (strCountSign(pyMultiLine, '\n') > 10) { - return 1; - } - return 0; -} +//uint8_t __platform_Asm_is_to_flash(char* pyMultiLine) { +//// if (strCountSign(pyMultiLine, '\n') > 10) { +//// return 1; +//// } +// return 0; +//} int32_t __saveStrToFlash(char* str, uint32_t flashStart, @@ -183,20 +183,20 @@ int32_t __saveStrToFlash(char* str, return 0; } -char* __platform_load_pikaAsm() { - return (char*)FLASH_PIKA_ASM_START_ADDR; -} +//char* __platform_load_pikaAsm() { +// return (char*)FLASH_PIKA_ASM_START_ADDR; +//} -int32_t __platform_save_pikaAsm(char* PikaAsm) { - if (0 == globalWriteAddress) { - __eriseSelecttedFlash(FLASH_PIKA_ASM_START_ADDR, - FLASH_PIKA_ASM_END_ADDR); - } - return __saveStrToFlash(PikaAsm, FLASH_PIKA_ASM_START_ADDR, - FLASH_PIKA_ASM_END_ADDR, &globalWriteAddress); -} +//int32_t __platform_save_pikaAsm(char* PikaAsm) { +// if (0 == globalWriteAddress) { +// __eriseSelecttedFlash(FLASH_PIKA_ASM_START_ADDR, +// FLASH_PIKA_ASM_END_ADDR); +// } +// return __saveStrToFlash(PikaAsm, FLASH_PIKA_ASM_START_ADDR, +// FLASH_PIKA_ASM_END_ADDR, &globalWriteAddress); +//} -int32_t __platform_save_pikaAsm_EOF() { +int32_t __save_pikaAsm_EOF() { for (int i = 0; i < 16; i++) { globalWriteAddress = flash_write_char(FLASH_PIKA_ASM_START_ADDR, globalWriteAddress, '\0'); @@ -336,7 +336,7 @@ void STM32_Code_flashHandler(void) { /* write EOF */ __saveStrToFlash("\n\n", FLASH_PIKA_ASM_START_ADDR, FLASH_PIKA_ASM_END_ADDR, &globalWriteAddress); - __platform_save_pikaAsm_EOF(); + __save_pikaAsm_EOF(); HAL_FLASH_Lock(); printf("[ OK ]: Write flash ok! \r\n"); diff --git a/bsp/stm32g030c8/MDK-ARM/stm32g030c8.uvprojx b/bsp/stm32g030c8/MDK-ARM/stm32g030c8.uvprojx index 5f7caf186..8a9528534 100644 --- a/bsp/stm32g030c8/MDK-ARM/stm32g030c8.uvprojx +++ b/bsp/stm32g030c8/MDK-ARM/stm32g030c8.uvprojx @@ -17,7 +17,7 @@ STM32G030C8Tx STMicroelectronics - Keil.STM32G0xx_DFP.1.4.0 + Keil.STM32G0xx_DFP.1.3.0 http://www.keil.com/pack/ IRAM(0x20000000-0x20001FFF) IROM(0x8000000-0x800FFFF) CLOCK(8000000) CPUTYPE("Cortex-M0+") TZ @@ -706,6 +706,11 @@ 1 ..\pikascript\pikascript-api/PikaStdLib-api.c + + PikaStdLib_PikaObj-api.c + 1 + ..\pikascript\pikascript-api/PikaStdLib_PikaObj-api.c + STM32G0_PWM-api.c 1 @@ -726,6 +731,16 @@ 1 ..\pikascript\pikascript-api/pikaScript.c + + machine_PWM-api.c + 1 + ..\pikascript\pikascript-api/machine_PWM-api.c + + + machine_Task-api.c + 1 + ..\pikascript\pikascript-api/machine_Task-api.c + PikaStdTask_Task-api.c 1 @@ -761,6 +776,16 @@ 1 ..\pikascript\pikascript-api/PikaStdDevice_PWM-api.c + + machine_GPIO-api.c + 1 + ..\pikascript\pikascript-api/machine_GPIO-api.c + + + machine-api.c + 1 + ..\pikascript\pikascript-api/machine-api.c + STM32G0_IIC-api.c 1 @@ -786,6 +811,16 @@ 1 ..\pikascript\pikascript-api/PikaStdDevice_Time-api.c + + machine_KEY-api.c + 1 + ..\pikascript\pikascript-api/machine_KEY-api.c + + + machine_LCD-api.c + 1 + ..\pikascript\pikascript-api/machine_LCD-api.c + PikaPiZero-api.c 1 @@ -811,6 +846,11 @@ 1 ..\pikascript\pikascript-api/STM32G0_Time-api.c + + machine_Time-api.c + 1 + ..\pikascript\pikascript-api/machine_Time-api.c + PikaStdLib_StringObj-api.c 1 @@ -821,11 +861,21 @@ 1 ..\pikascript\pikascript-api/PikaPiZero_LCD-api.c + + machine_ADC-api.c + 1 + ..\pikascript\pikascript-api/machine_ADC-api.c + PikaStdData_String-api.c 1 ..\pikascript\pikascript-api/PikaStdData_String-api.c + + machine_Point-api.c + 1 + ..\pikascript\pikascript-api/machine_Point-api.c + STM32G0_Task-api.c 1 @@ -846,6 +896,16 @@ 1 ..\pikascript\pikascript-api/PikaStdDevice_ADC-api.c + + machine_UART-api.c + 1 + ..\pikascript\pikascript-api/machine_UART-api.c + + + machine_RGB-api.c + 1 + ..\pikascript\pikascript-api/machine_RGB-api.c + PikaPiZero_KEY-api.c 1 @@ -856,61 +916,6 @@ 1 ..\pikascript\pikascript-api/STM32G0_ADC-api.c - - machine_ADC-api.c - 1 - ..\pikascript\pikascript-api\machine_ADC-api.c - - - machine_GPIO-api.c - 1 - ..\pikascript\pikascript-api\machine_GPIO-api.c - - - machine_KEY-api.c - 1 - ..\pikascript\pikascript-api\machine_KEY-api.c - - - machine_LCD-api.c - 1 - ..\pikascript\pikascript-api\machine_LCD-api.c - - - machine_Point-api.c - 1 - ..\pikascript\pikascript-api\machine_Point-api.c - - - machine_PWM-api.c - 1 - ..\pikascript\pikascript-api\machine_PWM-api.c - - - machine_RGB-api.c - 1 - ..\pikascript\pikascript-api\machine_RGB-api.c - - - machine_Task-api.c - 1 - ..\pikascript\pikascript-api\machine_Task-api.c - - - machine_Time-api.c - 1 - ..\pikascript\pikascript-api\machine_Time-api.c - - - machine_UART-api.c - 1 - ..\pikascript\pikascript-api\machine_UART-api.c - - - machine-api.c - 1 - ..\pikascript\pikascript-api\machine-api.c - diff --git a/bsp/stm32g030c8/pikascript/requestment.txt b/bsp/stm32g030c8/pikascript/requestment.txt index 9470a6142..e3275ca26 100644 --- a/bsp/stm32g030c8/pikascript/requestment.txt +++ b/bsp/stm32g030c8/pikascript/requestment.txt @@ -1,5 +1,5 @@ -pikascript-core==v1.4.0 -PikaStdLib==v1.4.0 +pikascript-core==v1.5.0rc +PikaStdLib==v1.5.0rc PikaStdDevice==v1.4.3 STM32G0==v1.1.1 PikaPiZero==v1.1.3 diff --git a/examples/GPIO/main.py b/examples/GPIO/main.py index bae8186d4..17ca1bb1e 100644 --- a/examples/GPIO/main.py +++ b/examples/GPIO/main.py @@ -18,6 +18,7 @@ print('mem.now :') mem.now() while True: + mem.now() io1.low() time.sleep_ms(500) io1.high() diff --git a/examples/PWM/main.py b/examples/PWM/main.py index f01943ceb..cef2c4ab4 100644 --- a/examples/PWM/main.py +++ b/examples/PWM/main.py @@ -7,8 +7,10 @@ pwm.setPin('PA8') pwm.setFrequency(2000) pwm.setDuty(0.5) pwm.enable() +mem = PikaStdLib.MemChecker() while True: + mem.now() time.sleep_ms(500) pwm.setDuty(0.5) time.sleep_ms(500) diff --git a/examples/Task/main.py b/examples/Task/main.py index 219488c76..68b009213 100644 --- a/examples/Task/main.py +++ b/examples/Task/main.py @@ -20,6 +20,7 @@ mem.max() def rgb_task(): rgb.flow() + mem.now() def led_task():