diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index 2b4fca539..b6ddb32ea 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -289,7 +289,7 @@ jobs: with: repository: espressif/esp-idf path: sdk/esp-idf - ref: v5.5-beta1 + ref: v5.5 submodules: recursive - uses: actions/setup-python@v5 with: @@ -303,6 +303,7 @@ jobs: pip3 install configobj pip3 install toml pip3 install fdt + pip3 install esptool - name: Run make run: | cd sdk/esp-idf diff --git a/Makefile b/Makefile index 40de5f8f7..9cbb4582e 100644 --- a/Makefile +++ b/Makefile @@ -388,7 +388,7 @@ OpenXR809: prebuild_OpenXR809 sdk/OpenXR809/project/oxr_sharedApp/shared sdk/Ope .PHONY: build-BK7231 build-BK7231: $(SDK_PATH)/apps/$(APP_NAME) - cd $(SDK_PATH)/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH) && sh $(APPS_BUILD_CMD) $(APP_NAME) $(APP_VERSION) $(TARGET_PLATFORM) + cd $(SDK_PATH)/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH) && bash $(APPS_BUILD_CMD) $(APP_NAME) $(APP_VERSION) $(TARGET_PLATFORM) rm $(SDK_PATH)/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH)/tools/generate/$(APP_NAME)_*.rbl || /bin/true rm $(SDK_PATH)/platforms/$(TARGET_PLATFORM)/toolchain/$(APPS_BUILD_PATH)/tools/generate/$(APP_NAME)_*.bin || /bin/true @@ -439,7 +439,7 @@ OpenESP32: prebuild_ESPIDF IDF_TARGET="esp32" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-32 IDF_TARGET="esp32" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-32 -j $(shell nproc) mkdir -p output/$(APP_VERSION) - esptool.py -c esp32 merge_bin -o output/$(APP_VERSION)/OpenESP32_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x1000 ./platforms/ESP-IDF/build-32/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-32/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-32/OpenBeken.bin + python3 -m esptool -c esp32 merge_bin -o output/$(APP_VERSION)/OpenESP32_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x1000 ./platforms/ESP-IDF/build-32/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-32/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-32/OpenBeken.bin cp ./platforms/ESP-IDF/build-32/OpenBeken.bin output/$(APP_VERSION)/OpenESP32_$(APP_VERSION).img .PHONY: OpenESP32C3 @@ -447,7 +447,7 @@ OpenESP32C3: prebuild_ESPIDF IDF_TARGET="esp32c3" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-c3 IDF_TARGET="esp32c3" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-c3 -j $(shell nproc) mkdir -p output/$(APP_VERSION) - esptool.py -c esp32c3 merge_bin -o output/$(APP_VERSION)/OpenESP32C3_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c3/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c3/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c3/OpenBeken.bin + python3 -m esptool -c esp32c3 merge_bin -o output/$(APP_VERSION)/OpenESP32C3_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c3/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c3/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c3/OpenBeken.bin cp ./platforms/ESP-IDF/build-c3/OpenBeken.bin output/$(APP_VERSION)/OpenESP32C3_$(APP_VERSION).img .PHONY: OpenESP32C2 @@ -455,7 +455,7 @@ OpenESP32C2: prebuild_ESPIDF IDF_TARGET="esp32c2" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-c2 IDF_TARGET="esp32c2" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-c2 -j $(shell nproc) mkdir -p output/$(APP_VERSION) - esptool.py -c esp32c2 merge_bin -o output/$(APP_VERSION)/OpenESP32C2_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c2/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c2/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c2/OpenBeken.bin + python3 -m esptool -c esp32c2 merge_bin -o output/$(APP_VERSION)/OpenESP32C2_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c2/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c2/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c2/OpenBeken.bin cp ./platforms/ESP-IDF/build-c2/OpenBeken.bin output/$(APP_VERSION)/OpenESP32C2_$(APP_VERSION).img .PHONY: OpenESP32C5 @@ -463,7 +463,7 @@ OpenESP32C5: prebuild_ESPIDF IDF_TARGET="esp32c5" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-c5 IDF_TARGET="esp32c5" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-c5 -j $(shell nproc) mkdir -p output/$(APP_VERSION) - esptool.py -c esp32c5 merge_bin -o output/$(APP_VERSION)/OpenESP32C5_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c5/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c5/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c5/OpenBeken.bin + python3 -m esptool -c esp32c5 merge_bin -o output/$(APP_VERSION)/OpenESP32C5_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c5/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c5/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c5/OpenBeken.bin cp ./platforms/ESP-IDF/build-c5/OpenBeken.bin output/$(APP_VERSION)/OpenESP32C5_$(APP_VERSION).img .PHONY: OpenESP32C61 @@ -471,7 +471,7 @@ OpenESP32C61: prebuild_ESPIDF IDF_TARGET="esp32c61" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-c61 IDF_TARGET="esp32c61" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-c61 -j $(shell nproc) mkdir -p output/$(APP_VERSION) - esptool.py -c esp32c61 merge_bin -o output/$(APP_VERSION)/OpenESP32C61_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c61/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c61/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c61/OpenBeken.bin + python3 -m esptool -c esp32c61 merge_bin -o output/$(APP_VERSION)/OpenESP32C61_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c61/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c61/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c61/OpenBeken.bin cp ./platforms/ESP-IDF/build-c61/OpenBeken.bin output/$(APP_VERSION)/OpenESP32C61_$(APP_VERSION).img .PHONY: OpenESP32C6 @@ -479,7 +479,7 @@ OpenESP32C6: prebuild_ESPIDF IDF_TARGET="esp32c6" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-c6 IDF_TARGET="esp32c6" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-c6 -j $(shell nproc) mkdir -p output/$(APP_VERSION) - esptool.py -c esp32c6 merge_bin -o output/$(APP_VERSION)/OpenESP32C6_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c6/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c6/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c6/OpenBeken.bin + python3 -m esptool -c esp32c6 merge_bin -o output/$(APP_VERSION)/OpenESP32C6_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-c6/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-c6/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-c6/OpenBeken.bin cp ./platforms/ESP-IDF/build-c6/OpenBeken.bin output/$(APP_VERSION)/OpenESP32C6_$(APP_VERSION).img .PHONY: OpenESP32S2 @@ -487,7 +487,7 @@ OpenESP32S2: prebuild_ESPIDF IDF_TARGET="esp32s2" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-s2 IDF_TARGET="esp32s2" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-s2 -j $(shell nproc) mkdir -p output/$(APP_VERSION) - esptool.py -c esp32s2 merge_bin -o output/$(APP_VERSION)/OpenESP32S2_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x1000 ./platforms/ESP-IDF/build-s2/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-s2/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-s2/OpenBeken.bin + python3 -m esptool -c esp32s2 merge_bin -o output/$(APP_VERSION)/OpenESP32S2_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x1000 ./platforms/ESP-IDF/build-s2/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-s2/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-s2/OpenBeken.bin cp ./platforms/ESP-IDF/build-s2/OpenBeken.bin output/$(APP_VERSION)/OpenESP32S2_$(APP_VERSION).img .PHONY: OpenESP32S3 @@ -495,7 +495,7 @@ OpenESP32S3: prebuild_ESPIDF IDF_TARGET="esp32s3" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake platforms/ESP-IDF -B platforms/ESP-IDF/build-s3 IDF_TARGET="esp32s3" APP_VERSION=$(APP_VERSION) OBK_VARIANT=$(OBK_VARIANT) cmake --build ./platforms/ESP-IDF/build-s3 -j $(shell nproc) mkdir -p output/$(APP_VERSION) - esptool.py -c esp32s3 merge_bin -o output/$(APP_VERSION)/OpenESP32S3_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-s3/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-s3/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-s3/OpenBeken.bin + python3 -m esptool -c esp32s3 merge_bin -o output/$(APP_VERSION)/OpenESP32S3_$(APP_VERSION).factory.bin --flash_mode dio --flash_size $(ESP_FSIZE) 0x0 ./platforms/ESP-IDF/build-s3/bootloader/bootloader.bin 0x8000 ./platforms/ESP-IDF/build-s3/partition_table/partition-table.bin 0x10000 ./platforms/ESP-IDF/build-s3/OpenBeken.bin cp ./platforms/ESP-IDF/build-s3/OpenBeken.bin output/$(APP_VERSION)/OpenESP32S3_$(APP_VERSION).img .PHONY: OpenESP8266 @@ -508,7 +508,7 @@ OpenESP8266: prebuild_ESP8266 -rm platforms/ESP-IDF/partitions.csv cp platforms/ESP8266/partitions-1mb.csv platforms/ESP8266/partitions.csv cd platforms/ESP8266/ && idf.py partition_table - python3 -m esptool -c esp8266 merge_bin -o output/$(APP_VERSION)/OpenESP8266_1MB_$(APP_VERSION).factory.bin --flash_mode dout --flash_size 1MB 0x0 ./platforms/ESP8266/build/bootloader/bootloader.bin 0x8000 ./platforms/ESP8266/build/partition_table/partition-table.bin 0x10000 ./platforms/ESP8266/build/OpenBeken.bin + python3 -m esptool -c esp8266 merge-bin -o output/$(APP_VERSION)/OpenESP8266_1MB_$(APP_VERSION).factory.bin --flash-mode dout --flash-size 1MB 0x0 ./platforms/ESP8266/build/bootloader/bootloader.bin 0x8000 ./platforms/ESP8266/build/partition_table/partition-table.bin 0x10000 ./platforms/ESP8266/build/OpenBeken.bin .PHONY: OpenTR6260 OpenTR6260: prebuild_OpenTR6260 diff --git a/platforms/BK723x/ps.c b/platforms/BK723x/ps.c index aafe33554..145feece5 100644 --- a/platforms/BK723x/ps.c +++ b/platforms/BK723x/ps.c @@ -56,4 +56,7 @@ int bk_wlan_power_save_set_level(BK_PS_LEVEL level) global_ps_level = level; return 0; -} \ No newline at end of file +} + +void __attribute__((weak)) phy_enter_11b_low_power(void) {} +void __attribute__((weak)) phy_exit_11b_low_power(void) {} diff --git a/platforms/obk_main.mk b/platforms/obk_main.mk index 727ed0a33..d39e04ab7 100644 --- a/platforms/obk_main.mk +++ b/platforms/obk_main.mk @@ -127,8 +127,8 @@ OBKM_SRC += $(OBK_SRCS)driver/drv_rn8209.c OBKM_SRC += $(OBK_SRCS)driver/drv_sgp.c OBKM_SRC += $(OBK_SRCS)driver/drv_shiftRegister.c OBKM_SRC += $(OBK_SRCS)driver/drv_sht3x.c -#OBKM_SRC += $(OBK_SRCS)driver/drv_sm15155e.c -#OBKM_SRC += $(OBK_SRCS)driver/drv_sm16703P.c +OBKM_SRC += $(OBK_SRCS)driver/drv_sm15155e.c +OBKM_SRC += $(OBK_SRCS)driver/drv_sm16703P.c OBKM_SRC += $(OBK_SRCS)driver/drv_sm2135.c OBKM_SRC += $(OBK_SRCS)driver/drv_sm2235.c OBKM_SRC += $(OBK_SRCS)driver/drv_soft_i2c.c @@ -140,7 +140,7 @@ OBKM_SRC += $(OBK_SRCS)driver/drv_spidma.c OBKM_SRC += $(OBK_SRCS)driver/drv_ssdp.c OBKM_SRC += $(OBK_SRCS)driver/drv_tasmotaDeviceGroups.c OBKM_SRC += $(OBK_SRCS)driver/drv_tclAC.c -OBKM_SRC += $(OBK_SRCS)driver/drv_test.c +OBKM_SRC += $(OBK_SRCS)driver/drv_test.c #OBKM_SRC += $(OBK_SRCS)driver/drv_test_charts.c OBKM_SRC += $(OBK_SRCS)driver/drv_test_drivers.c OBKM_SRC += $(OBK_SRCS)driver/drv_textScroller.c diff --git a/sdk/OpenBK7231N b/sdk/OpenBK7231N index 2a61aa189..75f1c12b6 160000 --- a/sdk/OpenBK7231N +++ b/sdk/OpenBK7231N @@ -1 +1 @@ -Subproject commit 2a61aa189bad9c0120eb636b00bb12cfbb03dd95 +Subproject commit 75f1c12b6164a6e38fe9936c7ab48ba969255fda diff --git a/sdk/OpenBK7231T b/sdk/OpenBK7231T index cd71a4061..eeba3418a 160000 --- a/sdk/OpenBK7231T +++ b/sdk/OpenBK7231T @@ -1 +1 @@ -Subproject commit cd71a406149a81d84336ac31969c068502753409 +Subproject commit eeba3418aae54a57932eaae7d8162b71ac2d0a20 diff --git a/sdk/beken_freertos_sdk b/sdk/beken_freertos_sdk index b782aa140..8aa7b6d19 160000 --- a/sdk/beken_freertos_sdk +++ b/sdk/beken_freertos_sdk @@ -1 +1 @@ -Subproject commit b782aa140f605ab7e54e6dc02f653a6d88e35d4d +Subproject commit 8aa7b6d1937c919aebd7a522b4f11da703525dba diff --git a/src/driver/drv_sm15155e.c b/src/driver/drv_sm15155e.c index 84dda1ea1..39b1708c4 100644 --- a/src/driver/drv_sm15155e.c +++ b/src/driver/drv_sm15155e.c @@ -11,7 +11,7 @@ LED_Map 0 1 3 2 4 */ -#if (PLATFORM_BK7231N || WINDOWS) && !PLATFORM_BEKEN_NEW +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N || WINDOWS #include "../new_cfg.h" diff --git a/src/driver/drv_sm16703P.c b/src/driver/drv_sm16703P.c index 94e3f5e2b..6cc5ebbf5 100644 --- a/src/driver/drv_sm16703P.c +++ b/src/driver/drv_sm16703P.c @@ -1,4 +1,4 @@ -#if (PLATFORM_BK7231N || WINDOWS) && !PLATFORM_BEKEN_NEW +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N || WINDOWS #include "../new_cfg.h" diff --git a/src/driver/drv_spi.c b/src/driver/drv_spi.c index 037b7fc47..4cd8e50e9 100644 --- a/src/driver/drv_spi.c +++ b/src/driver/drv_spi.c @@ -13,7 +13,10 @@ #include "../../../../platforms/bk7231t/bk7231t_os/beken378/os/FreeRTOSv9.0.0/FreeRTOS/Source/portable/Keil/ARM968es/portmacro.h" #endif // PLATFORM_BK7231T #endif // PLATFORM_BK7231N - +#if PLATFORM_BEKEN_NEW +#include "spi_pub.h" +uint32_t mode = SPI_MASTER; +#endif #include "../logging/logging.h" int SPI_DriverInit(void) { @@ -23,6 +26,8 @@ int SPI_DriverInit(void) { // Is called in dd.c // spi_init(); return 0; +#elif PLATFORM_BEKEN_NEW + return 0; #else ADDLOG_ERROR(LOG_FEATURE_DRV, "SPI_DriverInit not supported"); return -1; @@ -36,6 +41,8 @@ int SPI_DriverDeinit(void) { // Is called in dd.c // spi_exit(); return 0; +#elif PLATFORM_BEKEN_NEW + return 0; #else ADDLOG_ERROR(LOG_FEATURE_DRV, "SPI_DriverDeinit not supported"); return -1; @@ -43,8 +50,21 @@ int SPI_DriverDeinit(void) { } int SPI_Init(const spi_config_t *config) { -#if PLATFORM_BK7231N && !PLATFORM_BEKEN_NEW +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N +#if PLATFORM_BEKEN_NEW + struct spi_message msg; + msg.send_buf = os_malloc(sizeof(uint8_t)); + msg.send_len = 0; + msg.recv_buf = os_malloc(sizeof(uint8_t)); + msg.recv_len = 0; + mode = config->role == SPI_ROLE_MASTER ? SPI_MASTER : SPI_SLAVE; + int ret = bk_spi_master_dma_init((SPI_MODE_0 | SPI_MSB | mode), config->baud_rate, &msg); + free(msg.send_buf); + free(msg.recv_buf); + return ret; +#else return bk_spi_init(0, config); +#endif #elif PLATFORM_BK7231T && !PLATFORM_BEKEN_NEW int err = 0; @@ -93,6 +113,12 @@ int SPI_Init(const spi_config_t *config) { spi_trans.trans_done = 1; return err; +#elif PLATFORM_BEKEN_NEW + mode = config->role == SPI_ROLE_MASTER ? SPI_MASTER : SPI_SLAVE; + if(mode == SPI_MASTER) + return bk_spi_master_init(config->baud_rate, ((config->polarity == SPI_POLARITY_LOW ? 0 : SPI_CPOL) | (config->phase == SPI_PHASE_1ST_EDGE ? 0 : SPI_CPHA))); + else + return bk_spi_slave_init(config->baud_rate, ((config->polarity == SPI_POLARITY_LOW ? 0 : SPI_CPOL) | (config->phase == SPI_PHASE_1ST_EDGE ? 0 : SPI_CPHA))); #else ADDLOG_ERROR(LOG_FEATURE_DRV, "SPI_Init not supported"); return -1; @@ -115,6 +141,11 @@ int SPI_Deinit(void) { err |= sddev_control(ICU_DEV_NAME, CMD_CLK_PWR_DOWN, ¶m); return err; +#elif PLATFORM_BEKEN_NEW + if(mode == SPI_MASTER) + return bk_spi_master_deinit(); + else + return bk_spi_slave_deinit(); #else ADDLOG_ERROR(LOG_FEATURE_DRV, "SPI_Deinit not supported"); return -1; @@ -135,8 +166,17 @@ static inline int Spi_wait_for_ready() { #endif int SPI_WriteBytes(const void *data, uint32_t size) { -#if PLATFORM_BK7231N && !PLATFORM_BEKEN_NEW +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N +#if PLATFORM_BEKEN_NEW + struct spi_message msg; + msg.send_buf = data; + msg.send_len = size; + msg.recv_buf = NULL; + msg.recv_len = 0; + return bk_spi_dma_transfer(mode, &msg); +#else return bk_spi_write_bytes(0, data, size); +#endif #elif PLATFORM_BK7231T && !PLATFORM_BEKEN_NEW GLOBAL_INT_DECLARATION(); GLOBAL_INT_DISABLE(); @@ -159,6 +199,16 @@ int SPI_WriteBytes(const void *data, uint32_t size) { err |= Spi_wait_for_ready(); return err; +#elif PLATFORM_BEKEN_NEW + struct spi_message msg; + msg.send_buf = data; + msg.send_len = size; + msg.recv_buf = NULL; + msg.recv_len = 0; + if(mode == SPI_MASTER) + return bk_spi_master_xfer(&msg); + else + return bk_spi_slave_xfer(&msg); #else ADDLOG_ERROR(LOG_FEATURE_DRV, "SPI_WriteBytes not supported"); return -1; @@ -166,8 +216,17 @@ int SPI_WriteBytes(const void *data, uint32_t size) { } int SPI_ReadBytes(void *data, uint32_t size) { -#if PLATFORM_BK7231N && !PLATFORM_BEKEN_NEW +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N +#if PLATFORM_BEKEN_NEW + struct spi_message msg; + msg.recv_buf = data; + msg.recv_len = size; + msg.send_buf = NULL; + msg.send_len = 0; + return bk_spi_dma_transfer(mode, &msg); +#else return bk_spi_read_bytes(0, data, size); +#endif #elif PLATFORM_BK7231T && !PLATFORM_BEKEN_NEW GLOBAL_INT_DECLARATION(); GLOBAL_INT_DISABLE(); @@ -190,6 +249,16 @@ int SPI_ReadBytes(void *data, uint32_t size) { err |= Spi_wait_for_ready(); return err; +#elif PLATFORM_BEKEN_NEW + struct spi_message msg; + msg.recv_buf = data; + msg.recv_len = size; + msg.send_buf = NULL; + msg.send_len = 0; + if(mode == SPI_MASTER) + return bk_spi_master_xfer(&msg); + else + return bk_spi_slave_xfer(&msg); #else ADDLOG_ERROR(LOG_FEATURE_DRV, "SPI_ReadBytes not supported"); return -1; @@ -198,8 +267,17 @@ int SPI_ReadBytes(void *data, uint32_t size) { int SPI_Transmit(const void *txData, uint32_t txSize, void *rxData, uint32_t rxSize) { -#if PLATFORM_BK7231N && !PLATFORM_BEKEN_NEW +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N +#if PLATFORM_BEKEN_NEW + struct spi_message msg; + msg.send_buf = txData; + msg.send_len = txSize; + msg.recv_buf = rxData; + msg.recv_len = rxSize; + return bk_spi_dma_transfer(mode, &msg); +#else return bk_spi_transmit(0, txData, txSize, rxData, rxSize); +#endif #elif PLATFORM_BK7231T && !PLATFORM_BEKEN_NEW int err = 0; @@ -210,6 +288,16 @@ int SPI_Transmit(const void *txData, uint32_t txSize, void *rxData, err |= SPI_ReadBytes(rxData, rxSize); return err; +#elif PLATFORM_BEKEN_NEW + struct spi_message msg; + msg.send_buf = txData; + msg.send_len = txSize; + msg.recv_buf = rxData; + msg.recv_len = rxSize; + if(mode == SPI_MASTER) + return bk_spi_master_xfer(&msg); + else + return bk_spi_slave_xfer(&msg); #else ADDLOG_ERROR(LOG_FEATURE_DRV, "SPI_Transmit not supported"); return -1; diff --git a/src/driver/drv_spiLED.c b/src/driver/drv_spiLED.c index 72be6428b..f1060346b 100644 --- a/src/driver/drv_spiLED.c +++ b/src/driver/drv_spiLED.c @@ -1,4 +1,4 @@ -#if (PLATFORM_BK7231N || WINDOWS) && !PLATFORM_BEKEN_NEW +#if (PLATFORM_BK7231N || WINDOWS) || PLATFORM_BK7238 || PLATFORM_BK7252N #include "../new_cfg.h" @@ -162,7 +162,7 @@ void SPILED_Shutdown() { void SPILED_Init() { uint32_t val; -#if PLATFORM_BK7231N +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N val = GFUNC_MODE_SPI_USE_GPIO_14; sddev_control(GPIO_DEV_NAME, CMD_GPIO_ENABLE_SECOND, &val); diff --git a/src/driver/drv_spidma.c b/src/driver/drv_spidma.c index 5829eccb7..839d51301 100644 --- a/src/driver/drv_spidma.c +++ b/src/driver/drv_spidma.c @@ -1,6 +1,9 @@ -#if PLATFORM_BK7231N && !PLATFORM_BEKEN_NEW +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N #include "arm_arch.h" +#if PLATFORM_BEKEN_NEW +#include "sys_config.h" +#endif #include "drv_model_pub.h" #include "general_dma_pub.h" #include "gpio_pub.h" @@ -8,7 +11,11 @@ #include "spi_pub.h" #include "../../beken378/driver/general_dma/general_dma.h" +#if PLATFORM_BEKEN_NEW +#include "spi_bk7231n.h" +#else #include "../../beken378/driver/spi/spi.h" +#endif #include "../new_cfg.h" #include "../new_common.h" diff --git a/src/driver/drv_spidma.h b/src/driver/drv_spidma.h index ac8857ad5..06d222bda 100644 --- a/src/driver/drv_spidma.h +++ b/src/driver/drv_spidma.h @@ -2,7 +2,7 @@ #include "../new_common.h" -#if PLATFORM_BK7231N +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N #include "arm_arch.h" #include "drv_model_pub.h" @@ -14,6 +14,10 @@ #include "sys_ctrl_pub.h" #include "uart_pub.h" #include "spi_pub.h" +#if PLATFORM_BEKEN_NEW +#define GFUNC_MODE_SPI_USE_GPIO_14 GFUNC_MODE_SPI_GPIO_14 +#define GFUNC_MODE_SPI_USE_GPIO_16_17 GFUNC_MODE_SPI_GPIO_16_17 +#endif #elif WINDOWS diff --git a/src/obk_config.h b/src/obk_config.h index b3b4a1aab..bf294025f 100644 --- a/src/obk_config.h +++ b/src/obk_config.h @@ -242,7 +242,7 @@ #define ENABLE_DRIVER_HUE 1 //#define ENABLE_DRIVER_CHARGINGLIMIT 1 #define ENABLE_DRIVER_BATTERY 1 -#if PLATFORM_BK7231N && !PLATFORM_BEKEN_NEW +#if PLATFORM_BK7231N || PLATFORM_BK7238 || PLATFORM_BK7252N //#define ENABLE_DRIVER_PWM_GROUP 1 #define ENABLE_DRIVER_SM16703P 1 #define ENABLE_DRIVER_PIXELANIM 1