diff --git a/bsp/bl602/README.md b/bsp/bl602/README.md index 58cf56b91..c0d05902c 100644 --- a/bsp/bl602/README.md +++ b/bsp/bl602/README.md @@ -9,13 +9,62 @@ 2. Install SDK: > https://blog.csdn.net/Boantong_/article/details/125604649?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166617877716800182741996%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=166617877716800182741996&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-3-125604649-null-null.nonecase&utm_term=wb2&spm=1018.2226.3001.4450 -3. Move this bsp to SDK folder and make. +3. ``` bash -mv pikascript_bl602 Ai-Thinker-Wb2/ +mv pikascript_bl602 Ai-Thinker-Wb2 cd Ai-Thinker-Wb2/pikascript_bl602 sh make.sh ``` # How to Flash > https://blog.csdn.net/Boantong_/article/details/125781602?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166617877716800182741996%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=166617877716800182741996&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-125781602-null-null.nonecase&utm_term=wb2&spm=1018.2226.3001.4450 + +# IIC + +``` c + pika_dev* iic = pika_hal_open(PIKA_HAL_IIC, "IIC3"); + pika_hal_IIC_config iic_cfg = {0}; + iic_cfg.slave_addr = 0x12; + iic_cfg.mem_addr_ena = PIKA_HAL_IIC_MEM_ADDR_ENA_ENABLE; + iic_cfg.mem_addr = 0x00; + iic_cfg.speed = 400000; + uint32_t err = 0; + pika_hal_ioctl(iic, PIKA_HAL_IOCTL_CONFIG, &iic_cfg); + pika_hal_ioctl(iic, PIKA_HAL_IOCTL_ENABLE, NULL); + uint8_t res = 0; + err = pika_hal_read(iic, &res, 1); + if (0 != err) { + printf("read error, err=%d\r\n", err); + } + printf("IIC3 read reg=%02x, res=%02x\r\n", iic_cfg.mem_addr, res); +``` + +log: +``` +======[pikascript packages installed]====== +pikascript-core==v1.11.7 (2022/11/19 19:43:26) +PikaStdDevice==latest +PikaStdLib==v1.11.7 +=========================================== +hello pikascript +IIC: Open IIC3 on SCL:P12, SDA:P11 +IIC: Config IIC0, speed:400000, address_width:0,master_or_slave: 1 +IIC: Enable IIC0 on SCL:P12, SDA:P11 +IIC: Read 1 bytes from 0x12 +IIC: Read 1 bytes from 0x12, mem_addr:0x00 +IIC3 read reg=00, res=e7 +>>> [ Info] In PikaSciprt Demo... +======[pikascript packages installed]====== +pikascript-core==v1.11.7 (2022/11/19 19:43:26) +PikaStdDevice==latest +PikaStdLib==v1.11.7 +=========================================== +hello pikascript +IIC: Open IIC3 on SCL:P12, SDA:P11 +IIC: Config IIC0, speed:400000, address_width:0,master_or_slave: 1 +IIC: Enable IIC0 on SCL:P12, SDA:P11 +IIC: Read 1 bytes from 0x12 +IIC: Read 1 bytes from 0x12, mem_addr:0x00 +IIC3 read reg=00, res=e7 +``` diff --git a/bsp/bl602/boot/main.c b/bsp/bl602/boot/main.c index 9d159996a..5b7c04c26 100644 --- a/bsp/bl602/boot/main.c +++ b/bsp/bl602/boot/main.c @@ -2,10 +2,11 @@ #include #include #include +#include #include #include #include -#include "hosal_uart.h" +#include "../pikascript/pikascript-lib/PikaStdDevice/pika_hal.h" #include "pikaScript.h" volatile PikaObj* root = NULL; @@ -50,7 +51,7 @@ long __platform_ftell(FILE* stream) { } void main(void) { - bl_gpio_enable_input(4, 0, 0); + bl_gpio_enable_output(4, 0, 0); bl_gpio_output_set(4, false); printf("[ Info] In PikaSciprt Demo...\r\n"); root = pikaScriptInit(); diff --git a/bsp/bl602/boot/pika_config.h b/bsp/bl602/boot/pika_config.h index 5f39c9446..f8c596643 100644 --- a/bsp/bl602/boot/pika_config.h +++ b/bsp/bl602/boot/pika_config.h @@ -2,3 +2,4 @@ #define PIKA_OPTIMIZE PIKA_OPTIMIZE_SPEED #define PIKA_SHELL_SAVE_FILE_ENABLE 1 #define PIKA_SHELL_SAVE_FILE_NAME "/lfs/boot.py" +#define PIKA_DEBUG_ENABLE 1 diff --git a/bsp/bl602/make.sh b/bsp/bl602/make.sh index a28a4be75..85c898633 100644 --- a/bsp/bl602/make.sh +++ b/bsp/bl602/make.sh @@ -1,3 +1,4 @@ +clear rm /mnt/d/pikascript_bl602.bin cd pikascript && wine rust-msc-latest-win10.exe cd - diff --git a/bsp/bl602/pikascript/bouffalo.mk b/bsp/bl602/pikascript/bouffalo.mk index 3f0431034..fae696386 100644 --- a/bsp/bl602/pikascript/bouffalo.mk +++ b/bsp/bl602/pikascript/bouffalo.mk @@ -10,5 +10,9 @@ COMPONENT_OBJS := $(patsubst %.c,%.o, $(COMPONENT_SRCS)) COMPONENT_SRCDIRS := pikascript-core \ pikascript-api \ - pikascript-lib/pika_lvgl \ + pikascript-lib/BLIOT \ + pikascript-lib/PikaStdDevice \ pikascript-lib/PikaStdLib + +COMPONENT_ADD_LDFLAGS_HEAD = -Wl,--whole-archive +COMPONENT_ADD_LDFLAGS_TAIL = -Wl,--no-whole-archive diff --git a/bsp/bl602/pikascript/main.py b/bsp/bl602/pikascript/main.py index 6ebf63e78..3ec23b567 100644 --- a/bsp/bl602/pikascript/main.py +++ b/bsp/bl602/pikascript/main.py @@ -1,3 +1,9 @@ import PikaStdLib +import PikaStdDevice as std print('hello pikascript') mem = PikaStdLib.MemChecker() + +dac = std.DAC() +dac.setPin('P14') +dac.enable() +dac.write(1.3) diff --git a/bsp/bl602/pikascript/requestment.txt b/bsp/bl602/pikascript/requestment.txt index 5aad27417..0e6dc9a79 100644 --- a/bsp/bl602/pikascript/requestment.txt +++ b/bsp/bl602/pikascript/requestment.txt @@ -1,2 +1,4 @@ pikascript-core==v1.11.7 -PikaStdLib==v1.11.7 \ No newline at end of file +PikaStdLib==v1.11.7 +PikaStdDevice==v2.1.1 +BLIOT==v0.2.0 \ No newline at end of file diff --git a/bsp/stm32h750vb/pikascript/requestment.txt b/bsp/stm32h750vb/pikascript/requestment.txt index f7301addb..5aad27417 100644 --- a/bsp/stm32h750vb/pikascript/requestment.txt +++ b/bsp/stm32h750vb/pikascript/requestment.txt @@ -1,2 +1,2 @@ pikascript-core==v1.11.7 -PikaStdLib==v1.11.7 +PikaStdLib==v1.11.7 \ No newline at end of file