mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2025-10-29 19:43:22 +00:00
RTL8710C/RTL8720C support (#1468)
* Move delay us and wdt to hals, update workflow * rtl8720c initial * move uart to hal * rtl uart * obk adjustments * sdk adjustments, fix ota * add some features * fix some warnings * esp uart + tr6260/esp tcp_msl * add bl0937, adjust ota * enable artifacts merge * add forgotten ln882h delay * fix mqtt, pwm on boot * irq fix * fix wifi disconnect * update sdk, change lfs location and size * Update Makefile
This commit is contained in:
parent
8fba7dd31e
commit
2a9a7270f2
81
.github/workflows/workflow.yaml
vendored
81
.github/workflows/workflow.yaml
vendored
@ -22,9 +22,7 @@ jobs:
|
||||
new_release: ${{ steps.refs.outputs.new_release }}
|
||||
steps:
|
||||
- name: Source checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
uses: actions/checkout@v4
|
||||
- name: Update SDKs if required
|
||||
run: make update-submodules
|
||||
- name: Semantic Release
|
||||
@ -52,12 +50,11 @@ jobs:
|
||||
else
|
||||
export VERSION=${BRANCHTRANSLATED}_$(git rev-parse --short=12 HEAD)
|
||||
fi
|
||||
echo "new_release: ${{ steps.semantic.outputs.new_release_published }}"
|
||||
echo "version: ${VERSION}"
|
||||
echo "::set-output name=new_release::${{ steps.semantic.outputs.new_release_published }}"
|
||||
echo "::set-output name=short_ref::${BRANCHTRANSLATED}"
|
||||
echo "::set-output name=sha_short::SHA-$(git rev-parse --short=12 HEAD)"
|
||||
echo "::set-output name=version::${VERSION}"
|
||||
echo "new_release=${{ steps.semantic.outputs.new_release_published }}" >> $GITHUB_OUTPUT
|
||||
echo "short_ref=${BRANCHTRANSLATED}" >> $GITHUB_OUTPUT
|
||||
echo "sha_short=SHA-$(git rev-parse --short=12 HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
|
||||
|
||||
build2:
|
||||
name: Build Simulator
|
||||
@ -66,10 +63,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
|
||||
- name: Checkout simulator repository
|
||||
run: |
|
||||
@ -98,9 +95,9 @@ jobs:
|
||||
mkdir -Force output/${{ needs.refs.outputs.version }}
|
||||
cp obkSimulator_win32_${{ needs.refs.outputs.version }}.zip output/${{ needs.refs.outputs.version }}/obkSimulator_${{ needs.refs.outputs.version }}.zip
|
||||
- name: Upload build assets
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}
|
||||
name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}_sim
|
||||
path: output/${{ needs.refs.outputs.version }}/obkSimulator_${{ needs.refs.outputs.version }}.zip
|
||||
|
||||
build:
|
||||
@ -110,13 +107,11 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [OpenBK7231T, OpenBK7231N, OpenXR809, OpenBL602, OpenW800, OpenW600, OpenLN882H, OpenTR6260]
|
||||
platform: [OpenBK7231T, OpenBK7231N, OpenXR809, OpenBL602, OpenW800, OpenW600, OpenLN882H, OpenTR6260, OpenRTL87X0C]
|
||||
steps:
|
||||
- name: Source checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions/setup-python@v2
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.8'
|
||||
architecture: 'x64'
|
||||
@ -133,24 +128,21 @@ jobs:
|
||||
- name: Run make
|
||||
run: make APP_VERSION=${{ needs.refs.outputs.version }} APP_NAME=${{ matrix.platform }} ${{ matrix.platform }}
|
||||
- name: Save build assets
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}
|
||||
name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}_${{ matrix.platform }}
|
||||
path: |
|
||||
output/${{ needs.refs.outputs.version }}/OpenBK7231T_UA_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/OpenBK7231T_UG_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/OpenBK7231T_QIO_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/OpenBK7231N_QIO_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/OpenBK7231N_UG_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/OpenBK7231M_QIO_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_UA_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_UG_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_QIO_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}.rbl
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}.img
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}.bin
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}.fls
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_ota.img
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_gz.img
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_OTA.bin
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_OTA.bin.xz
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_OTA.bin
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_OTA.bin.xz
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_OTA.bin.xz.ota
|
||||
if-no-files-found: warn
|
||||
|
||||
@ -164,10 +156,15 @@ jobs:
|
||||
platform: [OpenESP32, OpenESP32C3, OpenESP32C2, OpenESP32C6, OpenESP32S3, OpenESP32S2]
|
||||
steps:
|
||||
- name: Source checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: SDK checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: actions/setup-python@v2
|
||||
repository: espressif/esp-idf
|
||||
path: sdk/esp-idf
|
||||
ref: v5.3.2
|
||||
submodules: recursive
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.8'
|
||||
architecture: 'x64'
|
||||
@ -188,24 +185,36 @@ jobs:
|
||||
cd ../..
|
||||
make APP_VERSION=${{ needs.refs.outputs.version }} APP_NAME=${{ matrix.platform }} ${{ matrix.platform }}
|
||||
- name: Save build assets
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}
|
||||
name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}_${{ matrix.platform }}
|
||||
path: |
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}.img
|
||||
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}.factory.bin
|
||||
if-no-files-found: warn
|
||||
|
||||
merge:
|
||||
name: Merge Artifacts
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [refs, build, build2, build_idf]
|
||||
#if: always() && needs.refs.outputs.new_release == 'true' && (github.ref == 'refs/heads/main' || github.ref_name == 'alpha')
|
||||
steps:
|
||||
- name: Merge Artifacts
|
||||
uses: actions/upload-artifact/merge@v4
|
||||
with:
|
||||
name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}
|
||||
#delete-merged: true
|
||||
|
||||
release:
|
||||
name: Semantic Release Images and Artifacts
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [ refs, build, build_idf, build2 ]
|
||||
needs: [merge, refs]
|
||||
if: always() && needs.refs.outputs.new_release == 'true' && (github.ref == 'refs/heads/main' || github.ref_name == 'alpha')
|
||||
steps:
|
||||
- name: Source checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Fetch build assets
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: ${{ env.APP_NAME }}_${{ needs.refs.outputs.version }}
|
||||
path: output/${{ needs.refs.outputs.version }}
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -35,3 +35,5 @@ configMemory.bin
|
||||
|
||||
# MSVC
|
||||
enc_temp_folder/**
|
||||
|
||||
*.su
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -33,3 +33,7 @@
|
||||
path = sdk/OpenTR6260
|
||||
url = https://github.com/NonPIayerCharacter/OpenTR6260.git
|
||||
branch = master
|
||||
[submodule "sdk/OpenRTL87X0C"]
|
||||
path = sdk/OpenRTL87X0C
|
||||
url = https://github.com/NonPIayerCharacter/OpenRTL87X0C.git
|
||||
branch = main
|
||||
|
||||
46
Makefile
46
Makefile
@ -31,11 +31,11 @@ submodules:
|
||||
ifdef GITHUB_ACTIONS
|
||||
@echo Submodules already checked out during setup
|
||||
else
|
||||
git submodule update --init --recursive --remote
|
||||
git submodule update --init --recursive
|
||||
endif
|
||||
|
||||
update-submodules: submodules
|
||||
git add sdk/OpenBK7231T sdk/OpenBK7231N sdk/OpenXR809 sdk/OpenBL602 sdk/OpenW800 sdk/OpenW600 sdk/OpenLN882H sdk/esp-idf
|
||||
git add sdk/OpenBK7231T sdk/OpenBK7231N sdk/OpenXR809 sdk/OpenBL602 sdk/OpenW800 sdk/OpenW600 sdk/OpenLN882H sdk/esp-idf sdk/OpenTR6260
|
||||
ifdef GITHUB_ACTIONS
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
@ -76,8 +76,10 @@ sdk/OpenLN882H/project/OpenBeken/app:
|
||||
|
||||
.PHONY: prebuild_OpenBK7231N prebuild_OpenBK7231T prebuild_OpenBL602 prebuild_OpenLN882H
|
||||
.PHONY: prebuild_OpenW600 prebuild_OpenW800 prebuild_OpenXR809 prebuild_ESPIDF prebuild_OpenTR6260
|
||||
.PHONY: prebuild_OpenRTL87X0C
|
||||
|
||||
prebuild_OpenBK7231N:
|
||||
git submodule update --init --recursive sdk/OpenBK7231N
|
||||
@if [ -e platforms/BK7231N/pre_build.sh ]; then \
|
||||
echo "prebuild found for OpenBK7231N"; \
|
||||
sh platforms/BK7231N/pre_build.sh; \
|
||||
@ -85,6 +87,7 @@ prebuild_OpenBK7231N:
|
||||
fi
|
||||
|
||||
prebuild_OpenBK7231T:
|
||||
git submodule update --init --recursive sdk/OpenBK7231T
|
||||
@if [ -e platforms/BK7231T/pre_build.sh ]; then \
|
||||
echo "prebuild found for OpenBK7231T"; \
|
||||
sh platforms/BK7231T/pre_build.sh; \
|
||||
@ -92,6 +95,7 @@ prebuild_OpenBK7231T:
|
||||
fi
|
||||
|
||||
prebuild_OpenBL602:
|
||||
git submodule update --init --recursive sdk/OpenBL602
|
||||
@if [ -e platforms/BL602/pre_build.sh ]; then \
|
||||
echo "prebuild found for OpenBL602"; \
|
||||
sh platforms/BL602/pre_build.sh; \
|
||||
@ -99,6 +103,7 @@ prebuild_OpenBL602:
|
||||
fi
|
||||
|
||||
prebuild_OpenLN882H:
|
||||
git submodule update --init --recursive sdk/OpenLN882H
|
||||
@if [ -e platforms/LN882H/pre_build.sh ]; then \
|
||||
echo "prebuild found for OpenLN882H"; \
|
||||
sh platforms/LN882H/pre_build.sh; \
|
||||
@ -106,6 +111,7 @@ prebuild_OpenLN882H:
|
||||
fi
|
||||
|
||||
prebuild_OpenW600:
|
||||
git submodule update --init --recursive sdk/OpenW600
|
||||
@if [ -e platforms/W600/pre_build.sh ]; then \
|
||||
echo "prebuild found for OpenW600"; \
|
||||
sh platforms/W600/pre_build.sh; \
|
||||
@ -113,6 +119,7 @@ prebuild_OpenW600:
|
||||
fi
|
||||
|
||||
prebuild_OpenW800:
|
||||
git submodule update --init --recursive sdk/OpenW800
|
||||
@if [ -e platforms/W800/pre_build.sh ]; then \
|
||||
echo "prebuild found for OpenW800"; \
|
||||
sh platforms/W800/pre_build.sh; \
|
||||
@ -120,6 +127,7 @@ prebuild_OpenW800:
|
||||
fi
|
||||
|
||||
prebuild_OpenXR809:
|
||||
git submodule update --init --recursive sdk/OpenXR809
|
||||
@if [ -e platforms/XR809/pre_build.sh ]; then \
|
||||
echo "prebuild found for OpenXR809"; \
|
||||
sh platforms/XR809/pre_build.sh; \
|
||||
@ -127,6 +135,7 @@ prebuild_OpenXR809:
|
||||
fi
|
||||
|
||||
prebuild_ESPIDF:
|
||||
#git submodule update --init --recursive sdk/esp-idf
|
||||
@if [ -e platforms/ESP-IDF/pre_build.sh ]; then \
|
||||
echo "prebuild found for ESP-IDF"; \
|
||||
sh platforms/ESP-IDF/pre_build.sh; \
|
||||
@ -134,10 +143,19 @@ prebuild_ESPIDF:
|
||||
fi
|
||||
|
||||
prebuild_OpenTR6260:
|
||||
git submodule update --init --recursive sdk/OpenTR6260
|
||||
@if [ -e platforms/TR6260/pre_build.sh ]; then \
|
||||
echo "prebuild found for TR6260"; \
|
||||
echo "prebuild found for OpenTR6260"; \
|
||||
sh platforms/TR6260/pre_build.sh; \
|
||||
else echo "prebuild for TR6260 not found ... "; \
|
||||
else echo "prebuild for OpenTR6260 not found ... "; \
|
||||
fi
|
||||
|
||||
prebuild_OpenRTL87X0C:
|
||||
git submodule update --init --recursive sdk/OpenRTL87X0C
|
||||
@if [ -e platforms/RTL87X0C/pre_build.sh ]; then \
|
||||
echo "prebuild found for OpenRTL87X0C"; \
|
||||
sh platforms/RTL87X0C/pre_build.sh; \
|
||||
else echo "prebuild for OpenRTL87X0C not found ... "; \
|
||||
fi
|
||||
|
||||
# Build main binaries
|
||||
@ -159,7 +177,7 @@ OpenXR809: prebuild_OpenXR809
|
||||
@echo Running build final time to check output
|
||||
$(MAKE) build-XR809;
|
||||
|
||||
build-XR809: submodules sdk/OpenXR809/project/oxr_sharedApp/shared sdk/OpenXR809/tools/gcc-arm-none-eabi-4_9-2015q2
|
||||
build-XR809: sdk/OpenXR809/project/oxr_sharedApp/shared sdk/OpenXR809/tools/gcc-arm-none-eabi-4_9-2015q2
|
||||
$(MAKE) -C sdk/OpenXR809/src CC_DIR=$(PWD)/sdk/OpenXR809/tools/gcc-arm-none-eabi-4_9-2015q2/bin
|
||||
$(MAKE) -C sdk/OpenXR809/src install CC_DIR=$(PWD)/sdk/OpenXR809/tools/gcc-arm-none-eabi-4_9-2015q2/bin
|
||||
$(MAKE) -C sdk/OpenXR809/project/oxr_sharedApp/gcc CC_DIR=$(PWD)/sdk/OpenXR809/tools/gcc-arm-none-eabi-4_9-2015q2/bin
|
||||
@ -168,12 +186,12 @@ build-XR809: submodules sdk/OpenXR809/project/oxr_sharedApp/shared sdk/OpenXR809
|
||||
cp sdk/OpenXR809/project/oxr_sharedApp/image/xr809/xr_system.img output/$(APP_VERSION)/OpenXR809_$(APP_VERSION).img
|
||||
|
||||
.PHONY: build-BK7231
|
||||
build-BK7231: submodules $(SDK_PATH)/apps/$(APP_NAME)
|
||||
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)
|
||||
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
|
||||
|
||||
OpenBL602: submodules sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared prebuild_OpenBL602
|
||||
OpenBL602: prebuild_OpenBL602 sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared
|
||||
$(MAKE) -C sdk/OpenBL602/customer_app/bl602_sharedApp USER_SW_VER=$(APP_VERSION) CONFIG_CHIP_NAME=BL602 CONFIG_LINK_ROM=1 -j
|
||||
$(MAKE) -C sdk/OpenBL602/customer_app/bl602_sharedApp USER_SW_VER=$(APP_VERSION) CONFIG_CHIP_NAME=BL602 bins
|
||||
mkdir -p output/$(APP_VERSION)
|
||||
@ -192,7 +210,7 @@ sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin: submodules
|
||||
cd sdk/OpenW600/tools && tar -xf ../support/*.tar.bz2
|
||||
|
||||
.PHONY: OpenW800
|
||||
OpenW800: sdk/OpenW800/tools/w800/csky/bin sdk/OpenW800/sharedAppContainer/sharedApp prebuild_OpenW800
|
||||
OpenW800: prebuild_OpenW800 sdk/OpenW800/tools/w800/csky/bin sdk/OpenW800/sharedAppContainer/sharedApp
|
||||
# if building new version, make sure "new_http.o" is deleted (it contains build time and version, so build time is set to actual time)
|
||||
rm -rf sdk/OpenW800/bin/build/w800/obj/sharedAppContainer/sharedApp/src/httpserver/new_http.o
|
||||
# define APP_Version so it's not "W800_Test" every time
|
||||
@ -202,14 +220,14 @@ OpenW800: sdk/OpenW800/tools/w800/csky/bin sdk/OpenW800/sharedAppContainer/share
|
||||
cp sdk/OpenW800/bin/w800/w800_ota.img output/$(APP_VERSION)/OpenW800_$(APP_VERSION)_ota.img
|
||||
|
||||
.PHONY: OpenW600
|
||||
OpenW600: sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin sdk/OpenW600/sharedAppContainer/sharedApp prebuild_OpenW600
|
||||
OpenW600: prebuild_OpenW600 sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin sdk/OpenW600/sharedAppContainer/sharedApp
|
||||
$(MAKE) -C sdk/OpenW600 TOOL_CHAIN_PATH="$(shell realpath sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin)/" APP_VERSION=$(APP_VERSION)
|
||||
mkdir -p output/$(APP_VERSION)
|
||||
cp sdk/OpenW600/bin/w600/w600.fls output/$(APP_VERSION)/OpenW600_$(APP_VERSION).fls
|
||||
cp sdk/OpenW600/bin/w600/w600_gz.img output/$(APP_VERSION)/OpenW600_$(APP_VERSION)_gz.img
|
||||
|
||||
.PHONY: OpenLN882H
|
||||
OpenLN882H: submodules sdk/OpenLN882H/project/OpenBeken/app prebuild_OpenLN882H
|
||||
OpenLN882H: prebuild_OpenLN882H sdk/OpenLN882H/project/OpenBeken/app
|
||||
CROSS_TOOLCHAIN_ROOT="/usr/" cmake sdk/OpenLN882H -B sdk/OpenLN882H/build
|
||||
CROSS_TOOLCHAIN_ROOT="/usr/" cmake --build ./sdk/OpenLN882H/build
|
||||
mkdir -p output/$(APP_VERSION)
|
||||
@ -276,6 +294,13 @@ OpenTR6260: prebuild_OpenTR6260
|
||||
cd sdk/OpenTR6260/scripts && APP_VERSION=$(APP_VERSION) bash build_tr6260s1.sh
|
||||
mkdir -p output/$(APP_VERSION)
|
||||
cp sdk/OpenTR6260/out/tr6260s1/standalone/tr6260s1_0x007000.bin output/$(APP_VERSION)/OpenTR6260_$(APP_VERSION).bin
|
||||
|
||||
.PHONY: OpenRTL87X0C
|
||||
OpenRTL87X0C: prebuild_OpenRTL87X0C
|
||||
$(MAKE) -C sdk/OpenRTL87X0C/project/OpenBeken/GCC-RELEASE APP_VERSION=$(APP_VERSION) -j $(shell nproc)
|
||||
mkdir -p output/$(APP_VERSION)
|
||||
cp sdk/OpenRTL87X0C/project/OpenBeken/GCC-RELEASE/application_is/Debug/bin/flash_is.bin output/$(APP_VERSION)/OpenRTL87X0C_$(APP_VERSION).bin
|
||||
cp sdk/OpenRTL87X0C/project/OpenBeken/GCC-RELEASE/application_is/Debug/bin/firmware_is.bin output/$(APP_VERSION)/OpenRTL87X0C_$(APP_VERSION)_ota.img
|
||||
|
||||
# clean .o files and output directory
|
||||
.PHONY: clean
|
||||
@ -287,6 +312,7 @@ clean:
|
||||
$(MAKE) -C sdk/OpenW800 clean
|
||||
$(MAKE) -C sdk/OpenW600 clean
|
||||
$(MAKE) -C sdk/OpenTR6260/scripts tr6260s1_clean
|
||||
$(MAKE) -C sdk/OpenRTL87X0C/project/OpenBeken/GCC-RELEASE clean
|
||||
test -d ./sdk/OpenLN882H/build && cmake --build ./sdk/OpenLN882H/build --target clean
|
||||
test -d ./platforms/ESP-IDF/build-32 && cmake --build ./platforms/ESP-IDF/build-32 --target clean
|
||||
test -d ./platforms/ESP-IDF/build-c3 && cmake --build ./platforms/ESP-IDF/build-c3 --target clean
|
||||
|
||||
@ -9,13 +9,8 @@ COMPONENT_PRIV_INCLUDEDIRS :=
|
||||
|
||||
## This component's src
|
||||
COMPONENT_SRCS :=
|
||||
|
||||
|
||||
COMPONENT_OBJS := $(patsubst %.c,%.o, $(COMPONENT_SRCS))
|
||||
COMPONENT_OBJS := $(patsubst %.S,%.o, $(COMPONENT_OBJS))
|
||||
|
||||
COMPONENT_SRCDIRS := src/ src/jsmn src/httpserver/ src/cmnds/ src/logging/ src/hal/bl602/ src/mqtt/ src/i2c/ src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs
|
||||
|
||||
|
||||
|
||||
|
||||
COMPONENT_SRCDIRS := src/ src/jsmn src/httpserver/ src/cmnds/ src/logging/ src/hal/bl602/ src/mqtt/ src/i2c/ src/cJSON src/base64 src/driver src/devicegroups src/bitmessage src/littlefs src/hal/generic
|
||||
|
||||
@ -294,6 +294,7 @@
|
||||
<ClCompile Include="src\hal\win32\hal_main_win32.c" />
|
||||
<ClCompile Include="src\hal\win32\hal_pins_win32.c" />
|
||||
<ClCompile Include="src\hal\win32\hal_wifi_win32.c" />
|
||||
<ClCompile Include="src\hal\win32\hal_uart_win32.c" />
|
||||
<ClCompile Include="src\hal\xr809\hal_flashConfig_xr809.c">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
|
||||
@ -92,6 +92,15 @@ set(PROJ_ALL_SRC
|
||||
../../../src/hal/espidf/hal_main_espidf.c
|
||||
../../../src/hal/espidf/hal_pins_espidf.c
|
||||
../../../src/hal/espidf/hal_wifi_espidf.c
|
||||
../../../src/hal/espidf/hal_uart_espidf.c
|
||||
../../../src/hal/generic/hal_adc_generic.c
|
||||
../../../src/hal/generic/hal_flashConfig_generic.c
|
||||
../../../src/hal/generic/hal_flashVars_generic.c
|
||||
../../../src/hal/generic/hal_generic.c
|
||||
../../../src/hal/generic/hal_main_generic.c
|
||||
../../../src/hal/generic/hal_pins_generic.c
|
||||
../../../src/hal/generic/hal_wifi_generic.c
|
||||
../../../src/hal/generic/hal_uart_generic.c
|
||||
../../../src/httpserver/hass.c
|
||||
../../../src/httpserver/http_basic_auth.c
|
||||
../../../src/httpserver/http_fns.c
|
||||
|
||||
@ -17,4 +17,6 @@ CONFIG_MBEDTLS_TLS_CLIENT_ONLY=y
|
||||
CONFIG_HAL_LOG_LEVEL_ERROR=y
|
||||
|
||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=n
|
||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=n
|
||||
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=n
|
||||
|
||||
CONFIG_LWIP_TCP_MSL=1000
|
||||
|
||||
@ -96,6 +96,14 @@ set(PROJ_ALL_SRC
|
||||
app/src/hal/ln882h/hal_main_ln882h.c
|
||||
app/src/hal/ln882h/hal_pins_ln882h.c
|
||||
app/src/hal/ln882h/hal_wifi_ln882h.c
|
||||
app/src/hal/generic/hal_adc_generic.c
|
||||
app/src/hal/generic/hal_flashConfig_generic.c
|
||||
app/src/hal/generic/hal_flashVars_generic.c
|
||||
app/src/hal/generic/hal_generic.c
|
||||
app/src/hal/generic/hal_main_generic.c
|
||||
app/src/hal/generic/hal_pins_generic.c
|
||||
app/src/hal/generic/hal_wifi_generic.c
|
||||
app/src/hal/generic/hal_uart_generic.c
|
||||
app/src/httpserver/hass.c
|
||||
app/src/httpserver/http_basic_auth.c
|
||||
app/src/httpserver/http_fns.c
|
||||
|
||||
140
platforms/RTL87X0C/OpenBeken.mk
Normal file
140
platforms/RTL87X0C/OpenBeken.mk
Normal file
@ -0,0 +1,140 @@
|
||||
OBK_DIR = ../../../../..
|
||||
|
||||
CFLAGS += -DPLATFORM_RTL87X0C -DUSER_SW_VER='"$(APP_VERSION)"'
|
||||
|
||||
SRC_C += ../../../../../platforms/RTL87X0C/main.c
|
||||
|
||||
SRC_C += $(OBK_DIR)/src/base64/base64.c
|
||||
SRC_C += $(OBK_DIR)/src/bitmessage/bitmessage_read.c
|
||||
SRC_C += $(OBK_DIR)/src/bitmessage/bitmessage_write.c
|
||||
SRC_C += $(OBK_DIR)/src/cJSON/cJSON.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_channels.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_eventHandlers.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_if.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_main.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_newLEDDriver_colors.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_newLEDDriver.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_repeatingEvents.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_script.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_simulatorOnly.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_tasmota.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_tcp.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_test.c
|
||||
SRC_C += $(OBK_DIR)/src/cmnds/cmd_tokenizer.c
|
||||
SRC_C += $(OBK_DIR)/src/devicegroups/deviceGroups_read.c
|
||||
SRC_C += $(OBK_DIR)/src/devicegroups/deviceGroups_util.c
|
||||
SRC_C += $(OBK_DIR)/src/devicegroups/deviceGroups_write.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_main.c
|
||||
#SRC_C += $(OBK_DIR)/src/hal/rtl87x0c/hal_adc_rtl87x0c.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/rtl87x0c/hal_flashConfig_rtl87x0c.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/rtl87x0c/hal_flashVars_rtl87x0c.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/rtl87x0c/hal_generic_rtl87x0c.c
|
||||
#SRC_C += $(OBK_DIR)/src/hal/rtl87x0c/hal_main_rtl87x0c.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/rtl87x0c/hal_pins_rtl87x0c.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/rtl87x0c/hal_wifi_rtl87x0c.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/rtl87x0c/hal_uart_rtl87x0c.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/generic/hal_adc_generic.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/generic/hal_flashConfig_generic.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/generic/hal_flashVars_generic.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/generic/hal_generic.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/generic/hal_main_generic.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/generic/hal_pins_generic.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/generic/hal_wifi_generic.c
|
||||
SRC_C += $(OBK_DIR)/src/hal/generic/hal_uart_generic.c
|
||||
SRC_C += $(OBK_DIR)/src/httpserver/hass.c
|
||||
SRC_C += $(OBK_DIR)/src/httpserver/http_basic_auth.c
|
||||
SRC_C += $(OBK_DIR)/src/httpserver/http_fns.c
|
||||
SRC_C += $(OBK_DIR)/src/httpserver/http_tcp_server.c
|
||||
SRC_C += $(OBK_DIR)/src/httpserver/new_tcp_server.c
|
||||
SRC_C += $(OBK_DIR)/src/httpserver/json_interface.c
|
||||
SRC_C += $(OBK_DIR)/src/httpserver/new_http.c
|
||||
SRC_C += $(OBK_DIR)/src/httpserver/rest_interface.c
|
||||
SRC_C += $(OBK_DIR)/src/mqtt/new_mqtt_deduper.c
|
||||
SRC_C += $(OBK_DIR)/src/jsmn/jsmn.c
|
||||
SRC_C += $(OBK_DIR)/src/logging/logging.c
|
||||
SRC_C += $(OBK_DIR)/src/mqtt/new_mqtt.c
|
||||
SRC_C += $(OBK_DIR)/src/new_cfg.c
|
||||
SRC_C += $(OBK_DIR)/src/new_common.c
|
||||
SRC_C += $(OBK_DIR)/src/new_ping.c
|
||||
SRC_C += $(OBK_DIR)/src/new_pins.c
|
||||
SRC_C += $(OBK_DIR)/src/rgb2hsv.c
|
||||
SRC_C += $(OBK_DIR)/src/tiny_crc8.c
|
||||
SRC_C += $(OBK_DIR)/src/user_main.c
|
||||
#SRC_C += $(OBK_DIR)/src/cmnds/cmd_send.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_adcButton.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_adcSmoother.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_aht2x.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_battery.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_bl_shared.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_bl0937.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_bl0942.c
|
||||
#SRC_C += $(OBK_DIR)/src/driver/drv_bmp280.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_bmpi2c.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_bp1658cj.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_bp5758d.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_bridge_driver.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_chargingLimit.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_charts.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_cht8305.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_cse7766.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_ddp.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_debouncer.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_dht_internal.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_dht.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_doorSensorWithDeepSleep.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_gn6932.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_hd2015.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_ht16k33.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_httpButtons.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_hue.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_kp18058.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_kp18068.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_max72xx_clock.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_max72xx_internal.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_max72xx_single.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_mcp9808.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_ntp_events.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_ntp.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_pt6523.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_pwm_groups.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_pwmToggler.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_pwrCal.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_rn8209.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_sgp.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_shiftRegister.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_sht3x.c
|
||||
#SRC_C += $(OBK_DIR)/src/driver/drv_sm15155e.c
|
||||
#SRC_C += $(OBK_DIR)/src/driver/drv_sm16703P.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_sm2135.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_sm2235.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_soft_i2c.c
|
||||
#SRC_C += $(OBK_DIR)/src/driver/drv_soft_spi.c
|
||||
#SRC_C += $(OBK_DIR)/src/driver/drv_spi_flash.c
|
||||
#SRC_C += $(OBK_DIR)/src/driver/drv_spi.c
|
||||
#SRC_C += $(OBK_DIR)/src/driver/drv_spidma.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_ssdp.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_tasmotaDeviceGroups.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_test_drivers.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_textScroller.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_tm_gn_display_shared.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_tm1637.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_tm1638.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_tuyaMCU.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_tuyaMCUSensor.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_uart.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_ucs1912.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_wemo.c
|
||||
SRC_C += $(OBK_DIR)/src/driver/drv_ds1820_simple.c
|
||||
#SRC_C += $(OBK_DIR)/src/httpclient/http_client.c
|
||||
#SRC_C += $(OBK_DIR)/src/httpclient/utils_net.c
|
||||
#SRC_C += $(OBK_DIR)/src/httpclient/utils_timer.c
|
||||
SRC_C += $(OBK_DIR)/src/i2c/drv_i2c_lcd_pcf8574t.c
|
||||
SRC_C += $(OBK_DIR)/src/i2c/drv_i2c_main.c
|
||||
SRC_C += $(OBK_DIR)/src/i2c/drv_i2c_mcp23017.c
|
||||
SRC_C += $(OBK_DIR)/src/i2c/drv_i2c_tc74.c
|
||||
SRC_C += $(OBK_DIR)/src/littlefs/lfs_util.c
|
||||
SRC_C += $(OBK_DIR)/src/littlefs/lfs.c
|
||||
SRC_C += $(OBK_DIR)/src/littlefs/our_lfs.c
|
||||
#SRC_C += $(OBK_DIR)/src/memory/memtest.c
|
||||
#SRC_C += $(OBK_DIR)/src/ota/ota.c
|
||||
#SRC_C += $(OBK_DIR)/src/sim/sim_uart.c
|
||||
56
platforms/RTL87X0C/main.c
Normal file
56
platforms/RTL87X0C/main.c
Normal file
@ -0,0 +1,56 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "diag.h"
|
||||
#include "main.h"
|
||||
#include "wifi_constants.h"
|
||||
#include "hal_misc.h"
|
||||
#include "hal_sys_ctrl.h"
|
||||
#include "efuse_logical_api.h"
|
||||
|
||||
extern uint32_t get_cur_fw_idx(void);
|
||||
void Main_Init();
|
||||
void Main_OnEverySecond();
|
||||
|
||||
hal_reset_reason_t reset_reason;
|
||||
rtw_mode_t wifi_mode = RTW_MODE_STA;
|
||||
TaskHandle_t g_sys_task_handle1;
|
||||
uint32_t current_fw_idx = 0;
|
||||
uint8_t wmac[6] = { 0 };
|
||||
|
||||
void print_wlan_help(void* arg) {}
|
||||
void hci_tp_close(void) {}
|
||||
void sys_task1(void* pvParameters)
|
||||
{
|
||||
Main_Init();
|
||||
for(;;)
|
||||
{
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
Main_OnEverySecond();
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
rtl8710c_reset_reason_get(&reset_reason);
|
||||
current_fw_idx = get_cur_fw_idx();
|
||||
|
||||
wlan_network();
|
||||
|
||||
hal_misc_swd_pin_ctrl(0);
|
||||
|
||||
efuse_logical_read(0x11A, 6, (uint8_t*)wmac);
|
||||
|
||||
xTaskCreate(
|
||||
sys_task1,
|
||||
"OpenBeken",
|
||||
8 * 256,
|
||||
NULL,
|
||||
3,
|
||||
&g_sys_task_handle1);
|
||||
|
||||
/* Enable Schedule, Start Kernel */
|
||||
vTaskStartScheduler();
|
||||
|
||||
/* Should NEVER reach here */
|
||||
return 0;
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
VPATH += $(OBK_PATH)
|
||||
DEFINE += -DUSER_SW_VER='"$(APP_VERSION)"'
|
||||
DEFINE += -DPLATFORM_TR6260
|
||||
DEFINE += -DTCP_MSL=1000
|
||||
|
||||
CSRCS += base64/base64.c
|
||||
CSRCS += bitmessage/bitmessage_read.c
|
||||
@ -30,6 +31,14 @@ CSRCS += hal/tr6260/hal_generic_tr6260.c
|
||||
CSRCS += hal/tr6260/hal_main_tr6260.c
|
||||
CSRCS += hal/tr6260/hal_pins_tr6260.c
|
||||
CSRCS += hal/tr6260/hal_wifi_tr6260.c
|
||||
CSRCS += hal/generic/hal_adc_generic.c
|
||||
CSRCS += hal/generic/hal_flashConfig_generic.c
|
||||
CSRCS += hal/generic/hal_flashVars_generic.c
|
||||
CSRCS += hal/generic/hal_generic.c
|
||||
CSRCS += hal/generic/hal_main_generic.c
|
||||
CSRCS += hal/generic/hal_pins_generic.c
|
||||
CSRCS += hal/generic/hal_wifi_generic.c
|
||||
CSRCS += hal/generic/hal_uart_generic.c
|
||||
CSRCS += httpserver/hass.c
|
||||
CSRCS += httpserver/http_basic_auth.c
|
||||
CSRCS += httpserver/http_fns.c
|
||||
|
||||
@ -58,6 +58,14 @@ CSRCS += $(_SHARED_APP)/hal/w800/hal_generic_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_main_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_pins_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_wifi_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_adc_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_flashConfig_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_flashVars_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_main_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_pins_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_wifi_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_uart_generic.c
|
||||
CSRCS += $(_SHARED_APP)/httpserver/hass.c
|
||||
CSRCS += $(_SHARED_APP)/httpserver/http_fns.c
|
||||
CSRCS += $(_SHARED_APP)/httpserver/http_tcp_server.c
|
||||
|
||||
@ -34,6 +34,14 @@ CSRCS += $(_SHARED_APP)/hal/w800/hal_generic_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_main_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_pins_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/w800/hal_wifi_w800.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_adc_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_flashConfig_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_flashVars_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_main_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_pins_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_wifi_generic.c
|
||||
CSRCS += $(_SHARED_APP)/hal/generic/hal_uart_generic.c
|
||||
CSRCS += $(_SHARED_APP)/httpserver/hass.c
|
||||
CSRCS += $(_SHARED_APP)/httpserver/http_fns.c
|
||||
CSRCS += $(_SHARED_APP)/httpserver/http_tcp_server.c
|
||||
|
||||
@ -53,6 +53,15 @@ SRCS += ../shared/src/hal/xr809/hal_pins_xr809
|
||||
SRCS += ../shared/src/hal/xr809/hal_flashConfig_xr809
|
||||
SRCS += ../shared/src/hal/xr809/hal_flashVars_xr809
|
||||
|
||||
SRCS += ../shared/src/hal/generic/hal_adc_generic
|
||||
SRCS += ../shared/src/hal/generic/hal_flashConfig_generic
|
||||
SRCS += ../shared/src/hal/generic/hal_flashVars_generic
|
||||
SRCS += ../shared/src/hal/generic/hal_generic
|
||||
SRCS += ../shared/src/hal/generic/hal_main_generic
|
||||
SRCS += ../shared/src/hal/generic/hal_pins_generic
|
||||
SRCS += ../shared/src/hal/generic/hal_wifi_generic
|
||||
SRCS += ../shared/src/hal/generic/hal_uart_generic
|
||||
|
||||
SRCS += ../shared/src/user_main
|
||||
|
||||
|
||||
|
||||
1
sdk/OpenRTL87X0C
Submodule
1
sdk/OpenRTL87X0C
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit f4710e02a72a50ef5e21c51aaf2010835ba600de
|
||||
@ -225,19 +225,22 @@ float getActiveRepeatingEvents(const char *s) {
|
||||
return RepeatingEvents_GetActiveCount();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DRIVER_BATTERY
|
||||
float getBatteryVoltage(const char* s)
|
||||
{
|
||||
return Battery_lastreading(OBK_BATT_VOLTAGE);
|
||||
}
|
||||
float getBatteryLevel(const char* s)
|
||||
{
|
||||
return Battery_lastreading(OBK_BATT_LEVEL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DRIVER_BL0937
|
||||
|
||||
float getVoltage(const char *s) {
|
||||
return DRV_GetReading(OBK_VOLTAGE);
|
||||
}
|
||||
#ifdef ENABLE_DRIVER_BATTERY
|
||||
float getBatteryVoltage(const char *s) {
|
||||
return Battery_lastreading(OBK_BATT_VOLTAGE);
|
||||
}
|
||||
float getBatteryLevel(const char *s) {
|
||||
return Battery_lastreading(OBK_BATT_LEVEL);
|
||||
}
|
||||
#endif
|
||||
|
||||
float getCurrent(const char *s) {
|
||||
return DRV_GetReading(OBK_CURRENT);
|
||||
@ -256,12 +259,6 @@ float getToday(const char *s) {
|
||||
return DRV_GetReading(OBK_CONSUMPTION_TODAY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
float getNTPOn(const char *s) {
|
||||
return NTP_IsTimeSynced();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
float getRand(const char *s) {
|
||||
@ -298,11 +295,22 @@ float getMonth(const char *s) {
|
||||
float getMDay(const char *s) {
|
||||
return NTP_GetMDay();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NTP
|
||||
|
||||
float getNTPOn(const char* s)
|
||||
{
|
||||
return NTP_IsTimeSynced();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLE_NTP_DST
|
||||
float isDST(const char *s){
|
||||
return Time_IsDST();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_NTP_SUNRISE_SUNSET
|
||||
|
||||
float getSunrise(const char *s) {
|
||||
@ -469,6 +477,7 @@ const constant_t g_constants[] = {
|
||||
////cnstdetail:"descr":"Current Year from NTP",
|
||||
////cnstdetail:"requires":""}
|
||||
{ "$year", &getYear },
|
||||
#ifdef ENABLE_DRIVER_BL0937
|
||||
////cnstdetail:{"name":"$yesterday",
|
||||
////cnstdetail:"title":"$yesterday",
|
||||
////cnstdetail:"descr":"",
|
||||
@ -479,6 +488,7 @@ const constant_t g_constants[] = {
|
||||
////cnstdetail:"descr":"",
|
||||
////cnstdetail:"requires":""}
|
||||
{ "$today", &getToday },
|
||||
#endif
|
||||
#if ENABLE_NTP_DST
|
||||
////cnstdetail:{"name":"$isDST",
|
||||
////cnstdetail:"title":"$isDST",
|
||||
@ -543,11 +553,13 @@ const constant_t g_constants[] = {
|
||||
//cnstdetail:"requires":""}
|
||||
{ "$rebootReason", &getRebootReason },
|
||||
#endif
|
||||
#ifndef NO_CHIP_TEMPERATURE
|
||||
//cnstdetail:{"name":"$intTemp",
|
||||
//cnstdetail:"title":"$intTemp",
|
||||
//cnstdetail:"descr":"Internal temperature (of WiFi module sensor)",
|
||||
//cnstdetail:"requires":""}
|
||||
{ "$intTemp", &getInternalTemperature },
|
||||
#endif
|
||||
};
|
||||
|
||||
static int g_totalConstants = sizeof(g_constants) / sizeof(g_constants[0]);
|
||||
|
||||
@ -29,6 +29,8 @@ int cmd_uartInitIndex = 0;
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/ledc.h"
|
||||
#include "esp_check.h"
|
||||
#elif PLATFORM_RTL87X0C
|
||||
#include "wifi_conf.h"
|
||||
#endif
|
||||
|
||||
#define HASH_SIZE 128
|
||||
@ -161,6 +163,20 @@ static commandResult_t CMD_PowerSave(const void* context, const char* cmd, const
|
||||
ADDLOG_INFO(LOG_FEATURE_CMD, "PowerSave disabled");
|
||||
esp_wifi_set_ps(WIFI_PS_NONE);
|
||||
}
|
||||
#elif PLATFORM_RTL87X0C
|
||||
if(!wifi_is_up(RTW_STA_INTERFACE))
|
||||
{
|
||||
ADDLOG_ERROR(LOG_FEATURE_CMD, "Wifi is not on or in AP mode, failed setting powersave!");
|
||||
return CMD_RES_ERROR;
|
||||
}
|
||||
if(bOn)
|
||||
{
|
||||
wifi_enable_powersave();
|
||||
}
|
||||
else
|
||||
{
|
||||
wifi_disable_powersave();
|
||||
}
|
||||
#else
|
||||
ADDLOG_INFO(LOG_FEATURE_CMD, "PowerSave is not implemented on this platform");
|
||||
#endif
|
||||
@ -293,7 +309,8 @@ static commandResult_t CMD_ClearAll(const void* context, const char* cmd, const
|
||||
CHANNEL_ClearAllChannels();
|
||||
CMD_ClearAllHandlers(0, 0, 0, 0);
|
||||
RepeatingEvents_Cmd_ClearRepeatingEvents(0, 0, 0, 0);
|
||||
#if defined(WINDOWS) || defined(PLATFORM_BL602) || defined(PLATFORM_BEKEN) || defined(PLATFORM_LN882H) || defined(PLATFORM_TR6260)
|
||||
#if defined(WINDOWS) || defined(PLATFORM_BL602) || defined(PLATFORM_BEKEN) || defined(PLATFORM_LN882H) \
|
||||
|| defined(PLATFORM_ESPIDF) || defined(PLATFORM_TR6260) || defined(PLATFORM_RTL87X0C)
|
||||
CMD_resetSVM(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
@ -855,7 +872,8 @@ void CMD_Init_Early() {
|
||||
CMD_RegisterCommand("IndexRefreshInterval", CMD_IndexRefreshInterval, NULL);
|
||||
|
||||
|
||||
#if (defined WINDOWS) || (defined PLATFORM_BEKEN) || (defined PLATFORM_BL602) || (defined PLATFORM_LN882H) || (defined PLATFORM_ESPIDF) || defined(PLATFORM_TR6260)
|
||||
#if (defined WINDOWS) || (defined PLATFORM_BEKEN) || (defined PLATFORM_BL602) || (defined PLATFORM_LN882H) \
|
||||
|| (defined PLATFORM_ESPIDF) || defined(PLATFORM_TR6260) || defined(PLATFORM_RTL87X0C)
|
||||
CMD_InitScripting();
|
||||
#endif
|
||||
if (!bSafeMode) {
|
||||
@ -872,7 +890,8 @@ void CMD_Init_Delayed() {
|
||||
if (CFG_HasFlag(OBK_FLAG_CMD_ENABLETCPRAWPUTTYSERVER)) {
|
||||
CMD_StartTCPCommandLine();
|
||||
}
|
||||
#if defined(PLATFORM_BEKEN) || defined(WINDOWS) || defined(PLATFORM_BL602) || defined(PLATFORM_ESPIDF)
|
||||
#if defined(PLATFORM_BEKEN) || defined(WINDOWS) || defined(PLATFORM_BL602) || defined(PLATFORM_ESPIDF) \
|
||||
|| defined(PLATFORM_RTL87X0C)
|
||||
UART_AddCommands();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -22,14 +22,25 @@
|
||||
|
||||
#define ELE_HW_TIME 1
|
||||
#define HW_TIMER_ID 0
|
||||
|
||||
#elif PLATFORM_BL602
|
||||
|
||||
#include "../../../../../../components/hal_drv/bl602_hal/hal_gpio.h"
|
||||
#include "../../../../../../components/hal_drv/bl602_hal/bl_gpio.h"
|
||||
|
||||
#elif PLATFORM_LN882H
|
||||
|
||||
#include "../../sdk/OpenLN882H/mcu/driver_ln882h/hal/hal_common.h"
|
||||
#include "../../sdk/OpenLN882H/mcu/driver_ln882h/hal/hal_gpio.h"
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
#include "gpio_irq_api.h"
|
||||
#include "../hal/rtl87x0c/hal_generic_rtl87x0c.h"
|
||||
extern rtlPinMapping_t g_pins[];
|
||||
rtlPinMapping_t* rtl_cf;
|
||||
rtlPinMapping_t* rtl_cf1;
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@ -63,22 +74,26 @@ static portTickType pulseStamp;
|
||||
|
||||
#if PLATFORM_W600
|
||||
|
||||
static void HlwCf1Interrupt(void* context) {
|
||||
static void HlwCf1Interrupt(void* context)
|
||||
{
|
||||
tls_clr_gpio_irq_status(GPIO_HLW_CF1_pin);
|
||||
g_vc_pulses++;
|
||||
}
|
||||
static void HlwCfInterrupt(void* context) {
|
||||
static void HlwCfInterrupt(void* context)
|
||||
{
|
||||
tls_clr_gpio_irq_status(GPIO_HLW_CF_pin);
|
||||
g_p_pulses++;
|
||||
}
|
||||
|
||||
#elif PLATFORM_BL602
|
||||
|
||||
static void HlwCf1Interrupt(void* arg) {
|
||||
static void HlwCf1Interrupt(void* arg)
|
||||
{
|
||||
g_vc_pulses++;
|
||||
bl_gpio_intmask(GPIO_HLW_CF1, 0);
|
||||
}
|
||||
static void HlwCfInterrupt(void* arg) {
|
||||
static void HlwCfInterrupt(void* arg)
|
||||
{
|
||||
g_p_pulses++;
|
||||
bl_gpio_intmask(GPIO_HLW_CF, 0);
|
||||
}
|
||||
@ -104,7 +119,7 @@ void GPIOA_IRQHandler()
|
||||
{
|
||||
uint32_t base = GetBaseForPin(GPIO_HLW_CF1);
|
||||
uint16_t gpio_pin = GetGPIOForPin(GPIO_HLW_CF1);
|
||||
if (hal_gpio_pin_get_it_flag(base, gpio_pin) == HAL_SET)
|
||||
if(hal_gpio_pin_get_it_flag(base, gpio_pin) == HAL_SET)
|
||||
{
|
||||
hal_gpio_pin_clr_it_flag(base, gpio_pin);
|
||||
g_vc_pulses++;
|
||||
@ -112,7 +127,7 @@ void GPIOA_IRQHandler()
|
||||
|
||||
base = GetBaseForPin(GPIO_HLW_CF);
|
||||
gpio_pin = GetGPIOForPin(GPIO_HLW_CF);
|
||||
if (hal_gpio_pin_get_it_flag(base, gpio_pin) == HAL_SET)
|
||||
if(hal_gpio_pin_get_it_flag(base, gpio_pin) == HAL_SET)
|
||||
{
|
||||
hal_gpio_pin_clr_it_flag(base, gpio_pin);
|
||||
g_p_pulses++;
|
||||
@ -123,7 +138,7 @@ void GPIOB_IRQHandler()
|
||||
{
|
||||
uint32_t base = GetBaseForPin(GPIO_HLW_CF1);
|
||||
uint16_t gpio_pin = GetGPIOForPin(GPIO_HLW_CF1);
|
||||
if (hal_gpio_pin_get_it_flag(base, gpio_pin) == HAL_SET)
|
||||
if(hal_gpio_pin_get_it_flag(base, gpio_pin) == HAL_SET)
|
||||
{
|
||||
hal_gpio_pin_clr_it_flag(base, gpio_pin);
|
||||
g_vc_pulses++;
|
||||
@ -131,69 +146,103 @@ void GPIOB_IRQHandler()
|
||||
|
||||
base = GetBaseForPin(GPIO_HLW_CF);
|
||||
gpio_pin = GetGPIOForPin(GPIO_HLW_CF);
|
||||
if (hal_gpio_pin_get_it_flag(base, gpio_pin) == HAL_SET)
|
||||
if(hal_gpio_pin_get_it_flag(base, gpio_pin) == HAL_SET)
|
||||
{
|
||||
hal_gpio_pin_clr_it_flag(base, gpio_pin);
|
||||
g_p_pulses++;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
void HlwCf1Interrupt(unsigned char pinNum) { // Service Voltage and Current
|
||||
void cf_irq_handler(uint32_t id, gpio_irq_event event)
|
||||
{
|
||||
g_p_pulses++;
|
||||
}
|
||||
|
||||
void cf1_irq_handler(uint32_t id, gpio_irq_event event)
|
||||
{
|
||||
g_vc_pulses++;
|
||||
}
|
||||
void HlwCfInterrupt(unsigned char pinNum) { // Service Power
|
||||
|
||||
#else
|
||||
|
||||
void HlwCf1Interrupt(unsigned char pinNum)
|
||||
{
|
||||
// Service Voltage and Current
|
||||
g_vc_pulses++;
|
||||
}
|
||||
void HlwCfInterrupt(unsigned char pinNum)
|
||||
{
|
||||
// Service Power
|
||||
g_p_pulses++;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
commandResult_t BL0937_PowerMax(const void *context, const char *cmd, const char *args, int cmdFlags) {
|
||||
float maxPower;
|
||||
commandResult_t BL0937_PowerMax(const void* context, const char* cmd, const char* args, int cmdFlags)
|
||||
{
|
||||
float maxPower;
|
||||
|
||||
if(args==0||*args==0) {
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER,"This command needs one argument");
|
||||
return CMD_RES_NOT_ENOUGH_ARGUMENTS;
|
||||
}
|
||||
maxPower = atof(args);
|
||||
if ((maxPower>200.0) && (maxPower<7200.0f))
|
||||
{
|
||||
BL0937_PMAX = maxPower;
|
||||
// UPDATE: now they are automatically saved
|
||||
CFG_SetPowerMeasurementCalibrationFloat(CFG_OBK_POWER_MAX, BL0937_PMAX);
|
||||
{
|
||||
char dbg[128];
|
||||
snprintf(dbg, sizeof(dbg),"PowerMax: set max to %f\n", BL0937_PMAX);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER,dbg);
|
||||
}
|
||||
}
|
||||
return CMD_RES_OK;
|
||||
if(args == 0 || *args == 0)
|
||||
{
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "This command needs one argument");
|
||||
return CMD_RES_NOT_ENOUGH_ARGUMENTS;
|
||||
}
|
||||
maxPower = atof(args);
|
||||
if((maxPower > 200.0) && (maxPower < 7200.0f))
|
||||
{
|
||||
BL0937_PMAX = maxPower;
|
||||
// UPDATE: now they are automatically saved
|
||||
CFG_SetPowerMeasurementCalibrationFloat(CFG_OBK_POWER_MAX, BL0937_PMAX);
|
||||
{
|
||||
char dbg[128];
|
||||
snprintf(dbg, sizeof(dbg), "PowerMax: set max to %f\n", BL0937_PMAX);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, dbg);
|
||||
}
|
||||
}
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
|
||||
void BL0937_Shutdown_Pins()
|
||||
{
|
||||
#if PLATFORM_W600
|
||||
|
||||
tls_gpio_irq_disable(GPIO_HLW_CF1_pin);
|
||||
tls_gpio_irq_disable(GPIO_HLW_CF_pin);
|
||||
|
||||
#elif PLATFORM_BL602
|
||||
//Todo how?
|
||||
#elif PLATFORM_BEKEN
|
||||
|
||||
gpio_int_disable(GPIO_HLW_CF1);
|
||||
gpio_int_disable(GPIO_HLW_CF);
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
gpio_irq_free(rtl_cf1->irq);
|
||||
gpio_irq_free(rtl_cf->irq);
|
||||
os_free(rtl_cf1->irq);
|
||||
os_free(rtl_cf->irq);
|
||||
rtl_cf1->irq = NULL;
|
||||
rtl_cf->irq = NULL;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void BL0937_Init_Pins() {
|
||||
void BL0937_Init_Pins()
|
||||
{
|
||||
int tmp;
|
||||
|
||||
// if not found, this will return the already set value
|
||||
tmp = PIN_FindPinIndexForRole(IOR_BL0937_SEL_n, -1);
|
||||
if (tmp != -1) {
|
||||
if(tmp != -1)
|
||||
{
|
||||
g_invertSEL = true;
|
||||
GPIO_HLW_SEL = tmp;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
g_invertSEL = false;
|
||||
GPIO_HLW_SEL = PIN_FindPinIndexForRole(IOR_BL0937_SEL, GPIO_HLW_SEL);
|
||||
}
|
||||
@ -201,10 +250,33 @@ void BL0937_Init_Pins() {
|
||||
GPIO_HLW_CF1 = PIN_FindPinIndexForRole(IOR_BL0937_CF1, GPIO_HLW_CF1);
|
||||
|
||||
#if PLATFORM_W600
|
||||
|
||||
GPIO_HLW_CF1_pin = HAL_GetGPIOPin(GPIO_HLW_CF1);
|
||||
GPIO_HLW_CF_pin = HAL_GetGPIOPin(GPIO_HLW_CF);
|
||||
//printf("GPIO_HLW_CF=%d GPIO_HLW_CF1=%d\n", GPIO_HLW_CF, GPIO_HLW_CF1);
|
||||
//printf("GPIO_HLW_CF1_pin=%d GPIO_HLW_CF_pin=%d\n", GPIO_HLW_CF1_pin, GPIO_HLW_CF_pin);
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
rtl_cf = g_pins + GPIO_HLW_CF;
|
||||
rtl_cf1 = g_pins + GPIO_HLW_CF1;
|
||||
if(rtl_cf->gpio != NULL)
|
||||
{
|
||||
hal_pinmux_unregister(rtl_cf->pin, PID_GPIO);
|
||||
os_free(rtl_cf->gpio);
|
||||
rtl_cf->gpio = NULL;
|
||||
}
|
||||
if(rtl_cf1->gpio != NULL)
|
||||
{
|
||||
hal_pinmux_unregister(rtl_cf1->pin, PID_GPIO);
|
||||
os_free(rtl_cf1->gpio);
|
||||
rtl_cf1->gpio = NULL;
|
||||
}
|
||||
rtl_cf1->irq = os_malloc(sizeof(gpio_irq_t));
|
||||
rtl_cf->irq = os_malloc(sizeof(gpio_irq_t));
|
||||
memset(rtl_cf1->irq, 0, sizeof(gpio_irq_t));
|
||||
memset(rtl_cf->irq, 0, sizeof(gpio_irq_t));
|
||||
|
||||
#endif
|
||||
|
||||
BL0937_PMAX = CFG_GetPowerMeasurementCalibrationFloat(CFG_OBK_POWER_MAX, BL0937_PMAX);
|
||||
@ -215,37 +287,63 @@ void BL0937_Init_Pins() {
|
||||
HAL_PIN_Setup_Input_Pullup(GPIO_HLW_CF1);
|
||||
|
||||
#if PLATFORM_W600
|
||||
|
||||
tls_gpio_isr_register(GPIO_HLW_CF1_pin, HlwCf1Interrupt, NULL);
|
||||
tls_gpio_irq_enable(GPIO_HLW_CF1_pin, WM_GPIO_IRQ_TRIG_FALLING_EDGE);
|
||||
|
||||
#elif PLATFORM_BL602
|
||||
tmp = hal_gpio_register_handler(HlwCf1Interrupt, GPIO_HLW_CF1, GPIO_INT_CONTROL_ASYNC, GPIO_INT_TRIG_NEG_PULSE, (void*) NULL);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER,"Registering CF1 handler status: %i \n", tmp);
|
||||
|
||||
tmp = hal_gpio_register_handler(HlwCf1Interrupt, GPIO_HLW_CF1, GPIO_INT_CONTROL_ASYNC, GPIO_INT_TRIG_NEG_PULSE, (void*)NULL);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "Registering CF1 handler status: %i \n", tmp);
|
||||
|
||||
#elif PLATFORM_LN882H
|
||||
|
||||
hal_gpio_pin_it_cfg(GetBaseForPin(GPIO_HLW_CF1), GetGPIOForPin(GPIO_HLW_CF1), GPIO_INT_FALLING);
|
||||
hal_gpio_pin_it_en(GetBaseForPin(GPIO_HLW_CF1), GetGPIOForPin(GPIO_HLW_CF1), HAL_ENABLE);
|
||||
NVIC_SetPriority(GetIRQForPin(GPIO_HLW_CF1), 1);
|
||||
NVIC_EnableIRQ(GetIRQForPin(GPIO_HLW_CF1));
|
||||
|
||||
#elif PLATFORM_BEKEN
|
||||
|
||||
gpio_int_enable(GPIO_HLW_CF1, IRQ_TRIGGER_FALLING_EDGE, HlwCf1Interrupt);
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
gpio_irq_init(rtl_cf1->irq, rtl_cf1->pin, cf1_irq_handler, NULL);
|
||||
gpio_irq_set(rtl_cf1->irq, IRQ_FALL, 1);
|
||||
gpio_irq_enable(rtl_cf1->irq);
|
||||
|
||||
#endif
|
||||
|
||||
HAL_PIN_Setup_Input_Pullup(GPIO_HLW_CF);
|
||||
|
||||
#if PLATFORM_W600
|
||||
|
||||
tls_gpio_isr_register(GPIO_HLW_CF_pin, HlwCfInterrupt, NULL);
|
||||
tls_gpio_irq_enable(GPIO_HLW_CF_pin, WM_GPIO_IRQ_TRIG_FALLING_EDGE);
|
||||
|
||||
#elif PLATFORM_BL602
|
||||
tmp = hal_gpio_register_handler(HlwCfInterrupt, GPIO_HLW_CF, GPIO_INT_CONTROL_ASYNC, GPIO_INT_TRIG_NEG_PULSE, (void*) NULL);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER,"Registering CF handler status: %i \n", tmp);
|
||||
|
||||
tmp = hal_gpio_register_handler(HlwCfInterrupt, GPIO_HLW_CF, GPIO_INT_CONTROL_ASYNC, GPIO_INT_TRIG_NEG_PULSE, (void*)NULL);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "Registering CF handler status: %i \n", tmp);
|
||||
|
||||
#elif PLATFORM_LN882H
|
||||
|
||||
hal_gpio_pin_it_cfg(GetBaseForPin(GPIO_HLW_CF), GetGPIOForPin(GPIO_HLW_CF), GPIO_INT_FALLING);
|
||||
hal_gpio_pin_it_en(GetBaseForPin(GPIO_HLW_CF), GetGPIOForPin(GPIO_HLW_CF), HAL_ENABLE);
|
||||
NVIC_SetPriority(GetIRQForPin(GPIO_HLW_CF), 1);
|
||||
NVIC_EnableIRQ(GetIRQForPin(GPIO_HLW_CF));
|
||||
|
||||
#elif PLATFORM_BEKEN
|
||||
|
||||
gpio_int_enable(GPIO_HLW_CF, IRQ_TRIGGER_FALLING_EDGE, HlwCfInterrupt);
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
gpio_irq_init(rtl_cf->irq, rtl_cf->pin, cf_irq_handler, NULL);
|
||||
gpio_irq_set(rtl_cf->irq, IRQ_FALL, 1);
|
||||
gpio_irq_enable(rtl_cf->irq);
|
||||
|
||||
#endif
|
||||
|
||||
g_vc_pulses = 0;
|
||||
@ -253,43 +351,51 @@ void BL0937_Init_Pins() {
|
||||
pulseStamp = xTaskGetTickCount();
|
||||
}
|
||||
|
||||
void BL0937_Init(void) {
|
||||
BL_Shared_Init();
|
||||
void BL0937_Init(void)
|
||||
{
|
||||
BL_Shared_Init();
|
||||
|
||||
PwrCal_Init(PWR_CAL_MULTIPLY, DEFAULT_VOLTAGE_CAL, DEFAULT_CURRENT_CAL,
|
||||
DEFAULT_POWER_CAL);
|
||||
PwrCal_Init(PWR_CAL_MULTIPLY, DEFAULT_VOLTAGE_CAL, DEFAULT_CURRENT_CAL,
|
||||
DEFAULT_POWER_CAL);
|
||||
|
||||
//cmddetail:{"name":"PowerMax","args":"[MaxPowerInW]",
|
||||
//cmddetail:"descr":"Sets the maximum power limit for BL measurement used to filter incorrect values",
|
||||
//cmddetail:"fn":"NULL);","file":"driver/drv_bl0937.c","requires":"",
|
||||
//cmddetail:"examples":""}
|
||||
CMD_RegisterCommand("PowerMax",BL0937_PowerMax, NULL);
|
||||
CMD_RegisterCommand("PowerMax", BL0937_PowerMax, NULL);
|
||||
|
||||
BL0937_Init_Pins();
|
||||
}
|
||||
|
||||
void BL0937_RunEverySecond(void) {
|
||||
float final_v;
|
||||
void BL0937_RunEverySecond(void)
|
||||
{
|
||||
float final_v;
|
||||
float final_c;
|
||||
float final_p;
|
||||
bool bNeedRestart;
|
||||
portTickType ticksElapsed;
|
||||
|
||||
bNeedRestart = false;
|
||||
if (g_invertSEL) {
|
||||
if (GPIO_HLW_SEL != PIN_FindPinIndexForRole(IOR_BL0937_SEL_n, GPIO_HLW_SEL)) {
|
||||
if(g_invertSEL)
|
||||
{
|
||||
if(GPIO_HLW_SEL != PIN_FindPinIndexForRole(IOR_BL0937_SEL_n, GPIO_HLW_SEL))
|
||||
{
|
||||
bNeedRestart = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (GPIO_HLW_SEL != PIN_FindPinIndexForRole(IOR_BL0937_SEL, GPIO_HLW_SEL)) {
|
||||
else
|
||||
{
|
||||
if(GPIO_HLW_SEL != PIN_FindPinIndexForRole(IOR_BL0937_SEL, GPIO_HLW_SEL))
|
||||
{
|
||||
bNeedRestart = true;
|
||||
}
|
||||
}
|
||||
if (GPIO_HLW_CF != PIN_FindPinIndexForRole(IOR_BL0937_CF, GPIO_HLW_CF)) {
|
||||
if(GPIO_HLW_CF != PIN_FindPinIndexForRole(IOR_BL0937_CF, GPIO_HLW_CF))
|
||||
{
|
||||
bNeedRestart = true;
|
||||
}
|
||||
if (GPIO_HLW_CF1 != PIN_FindPinIndexForRole(IOR_BL0937_CF1, GPIO_HLW_CF1)) {
|
||||
if(GPIO_HLW_CF1 != PIN_FindPinIndexForRole(IOR_BL0937_CF1, GPIO_HLW_CF1))
|
||||
{
|
||||
bNeedRestart = true;
|
||||
}
|
||||
|
||||
@ -303,7 +409,8 @@ void BL0937_RunEverySecond(void) {
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
if (bNeedRestart) {
|
||||
if(bNeedRestart)
|
||||
{
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "BL0937 pins have changed, will reset the interrupts");
|
||||
|
||||
BL0937_Shutdown_Pins();
|
||||
@ -318,30 +425,37 @@ void BL0937_RunEverySecond(void) {
|
||||
|
||||
|
||||
#endif
|
||||
if(g_sel) {
|
||||
if (g_invertSEL) {
|
||||
if(g_sel)
|
||||
{
|
||||
if(g_invertSEL)
|
||||
{
|
||||
res_c = g_vc_pulses;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
res_v = g_vc_pulses;
|
||||
}
|
||||
g_sel = false;
|
||||
} else {
|
||||
if (g_invertSEL) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(g_invertSEL)
|
||||
{
|
||||
res_v = g_vc_pulses;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
res_c = g_vc_pulses;
|
||||
}
|
||||
g_sel = true;
|
||||
}
|
||||
HAL_PIN_SetOutputValue(GPIO_HLW_SEL, g_sel);
|
||||
HAL_PIN_SetOutputValue(GPIO_HLW_SEL, g_sel);
|
||||
g_vc_pulses = 0;
|
||||
|
||||
res_p = g_p_pulses;
|
||||
g_p_pulses = 0;
|
||||
#if PLATFORM_BEKEN
|
||||
GLOBAL_INT_RESTORE();
|
||||
GLOBAL_INT_RESTORE();
|
||||
#else
|
||||
|
||||
#endif
|
||||
@ -349,7 +463,7 @@ void BL0937_RunEverySecond(void) {
|
||||
pulseStamp = xTaskGetTickCount();
|
||||
//addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER,"Voltage pulses %i, current %i, power %i\n", res_v, res_c, res_p);
|
||||
|
||||
PwrCal_Scale(res_v, res_c, res_p, &final_v, &final_c, &final_p);
|
||||
PwrCal_Scale(res_v, res_c, res_p, &final_v, &final_c, &final_p);
|
||||
|
||||
final_v *= (float)ticksElapsed;
|
||||
final_v /= (1000.0f / (float)portTICK_PERIOD_MS);
|
||||
@ -360,25 +474,27 @@ void BL0937_RunEverySecond(void) {
|
||||
final_p *= (float)ticksElapsed;
|
||||
final_p /= (1000.0f / (float)portTICK_PERIOD_MS);
|
||||
|
||||
/* patch to limit max power reading, filter random reading errors */
|
||||
if (final_p > BL0937_PMAX)
|
||||
{
|
||||
/* MAX value breach, use last value */
|
||||
{
|
||||
char dbg[128];
|
||||
snprintf(dbg, sizeof(dbg),"Power reading: %f exceeded MAX limit: %f, Last: %f\n", final_p, BL0937_PMAX, last_p);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, dbg);
|
||||
}
|
||||
final_p = last_p;
|
||||
} else {
|
||||
/* Valid value save for next time */
|
||||
last_p = final_p;
|
||||
}
|
||||
/* patch to limit max power reading, filter random reading errors */
|
||||
if(final_p > BL0937_PMAX)
|
||||
{
|
||||
/* MAX value breach, use last value */
|
||||
{
|
||||
char dbg[128];
|
||||
snprintf(dbg, sizeof(dbg), "Power reading: %f exceeded MAX limit: %f, Last: %f\n", final_p, BL0937_PMAX, last_p);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, dbg);
|
||||
}
|
||||
final_p = last_p;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Valid value save for next time */
|
||||
last_p = final_p;
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
char dbg[128];
|
||||
snprintf(dbg, sizeof(dbg),"Voltage %f, current %f, power %f\n", final_v, final_c, final_p);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER,dbg);
|
||||
snprintf(dbg, sizeof(dbg), "Voltage %f, current %f, power %f\n", final_v, final_c, final_p);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, dbg);
|
||||
}
|
||||
#endif
|
||||
BL_ProcessUpdate(final_v, final_c, final_p, NAN, NAN);
|
||||
|
||||
@ -33,48 +33,13 @@ our DHT sensors wrapper is in drv_dht.c
|
||||
#include "drv_local.h"
|
||||
#include "drv_dht_internal.h"
|
||||
#include <math.h>
|
||||
#include "../hal/hal_generic.h"
|
||||
|
||||
#define TIMEOUT UINT32_MAX
|
||||
|
||||
void usleep2(int r) //delay function do 10*r nops, because rtos_delay_milliseconds is too much
|
||||
{
|
||||
#ifdef WIN32
|
||||
// not possible on Windows port
|
||||
#elif PLATFORM_BL602
|
||||
for (volatile int i = 0; i < r; i++) {
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
#elif PLATFORM_W600
|
||||
for (volatile int i = 0; i < r; i++) {
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
#elif PLATFORM_ESPIDF
|
||||
usleep(r);
|
||||
#else
|
||||
for (volatile int i = 0; i < r; i++) {
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
#endif
|
||||
HAL_Delay_us(r);
|
||||
}
|
||||
|
||||
#define delay(x) usleep2(x*1000);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "drv_ds1820_simple.h"
|
||||
#include "../hal/hal_generic.h"
|
||||
#if PLATFORM_ESPIDF
|
||||
#include "freertos/task.h"
|
||||
#define noInterrupts() portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;taskENTER_CRITICAL(&mux)
|
||||
@ -22,81 +23,7 @@ static int ds18_conversionPeriod = 0;
|
||||
// usleep adopted from DHT driver
|
||||
void usleepds(int r)
|
||||
{
|
||||
#ifdef WIN32
|
||||
// not possible on Windows port
|
||||
#elif PLATFORM_BL602
|
||||
for(volatile int i = 0; i < r; i++)
|
||||
{
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); // 5
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); //10
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
#elif PLATFORM_W600
|
||||
for(volatile int i = 0; i < r; i++)
|
||||
{
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); // 5
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
#elif PLATFORM_W800
|
||||
for(volatile int i = 0; i < r; i++)
|
||||
{
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); // 5
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); //10
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); //15
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); //20
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
#elif PLATFORM_BEKEN
|
||||
float adj = 1;
|
||||
if(g_powersave) adj = 1.5;
|
||||
usleep((17 * r * adj) / 10); // "1" is to fast and "2" to slow, 1.7 seems better than 1.5 (only from observing readings, no scope involved)
|
||||
#elif PLATFORM_LN882H
|
||||
usleep(5 * r); // "5" seems o.k
|
||||
#elif PLATFORM_ESPIDF
|
||||
usleep(r);
|
||||
#elif PLATFORM_TR6260
|
||||
usdelay(r);
|
||||
#else
|
||||
for(volatile int i = 0; i < r; i++)
|
||||
{
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
#endif
|
||||
HAL_Delay_us(r);
|
||||
}
|
||||
|
||||
// add some "special timing" for Beken - works w/o and with powerSave 1 for me
|
||||
|
||||
@ -5,108 +5,7 @@
|
||||
#include "../cmnds/cmd_public.h"
|
||||
#include "../cmnds/cmd_local.h"
|
||||
#include "../logging/logging.h"
|
||||
|
||||
#if PLATFORM_BK7231T | PLATFORM_BK7231N
|
||||
#include "../../beken378/func/user_driver/BkDriverUart.h"
|
||||
#endif
|
||||
|
||||
#if PLATFORM_BL602
|
||||
#include <vfs.h>
|
||||
#include <bl_uart.h>
|
||||
#include <bl_irq.h>
|
||||
#include <event_device.h>
|
||||
#include <cli.h>
|
||||
#include <aos/kernel.h>
|
||||
#include <aos/yloop.h>
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <timers.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <vfs.h>
|
||||
#include <aos/kernel.h>
|
||||
#include <aos/yloop.h>
|
||||
#include <event_device.h>
|
||||
#include <cli.h>
|
||||
|
||||
#include <lwip/tcpip.h>
|
||||
#include <lwip/sockets.h>
|
||||
#include <lwip/netdb.h>
|
||||
#include <lwip/tcp.h>
|
||||
#include <lwip/err.h>
|
||||
#include <http_client.h>
|
||||
#include <netutils/netutils.h>
|
||||
|
||||
#include <bl602_glb.h>
|
||||
#include <bl602_hbn.h>
|
||||
|
||||
#include <bl_uart.h>
|
||||
#include <bl_chip.h>
|
||||
#include <bl_wifi.h>
|
||||
#include <hal_wifi.h>
|
||||
#include <bl_sec.h>
|
||||
#include <bl_cks.h>
|
||||
#include <bl_irq.h>
|
||||
#include <bl_dma.h>
|
||||
#include <bl_timer.h>
|
||||
#include <bl_gpio_cli.h>
|
||||
#include <bl_wdt_cli.h>
|
||||
#include <hal_uart.h>
|
||||
#include <hal_sys.h>
|
||||
#include <hal_gpio.h>
|
||||
#include <hal_boot2.h>
|
||||
#include <hal_board.h>
|
||||
#include <looprt.h>
|
||||
#include <loopset.h>
|
||||
#include <sntp.h>
|
||||
#include <bl_sys_time.h>
|
||||
#include <bl_sys.h>
|
||||
#include <bl_sys_ota.h>
|
||||
#include <bl_romfs.h>
|
||||
#include <fdt.h>
|
||||
#include <device/vfs_uart.h>
|
||||
#include <utils_log.h>
|
||||
#include <bl602_uart.h>
|
||||
|
||||
#include <easyflash.h>
|
||||
#include <bl60x_fw_api.h>
|
||||
#include <wifi_mgmr_ext.h>
|
||||
#include <utils_log.h>
|
||||
#include <libfdt.h>
|
||||
#include <blog.h>
|
||||
// backlog logtype none; startDriver BL0942
|
||||
#endif
|
||||
#if PLATFORM_BK7231T | PLATFORM_BK7231N
|
||||
// from uart_bk.c
|
||||
extern void bk_send_byte(UINT8 uport, UINT8 data);
|
||||
int g_chosenUART = BK_UART_1;
|
||||
#elif WINDOWS
|
||||
|
||||
#elif PLATFORM_BL602
|
||||
//int g_fd;
|
||||
uint8_t g_id = 1;
|
||||
int fd_console = -1;
|
||||
#elif PLATFORM_ESPIDF
|
||||
#include "driver/uart.h"
|
||||
#include "driver/gpio.h"
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32C6
|
||||
#define RX1_PIN GPIO_NUM_7
|
||||
#define TX1_PIN GPIO_NUM_5
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
|
||||
#define RX1_PIN GPIO_NUM_6
|
||||
#define TX1_PIN GPIO_NUM_7
|
||||
#else
|
||||
#define RX1_PIN UART_PIN_NO_CHANGE
|
||||
#define TX1_PIN UART_PIN_NO_CHANGE
|
||||
#endif
|
||||
uart_port_t uartnum = UART_NUM_0;
|
||||
static QueueHandle_t uart_queue;
|
||||
uint8_t* data = NULL;
|
||||
#else
|
||||
#endif
|
||||
#include "../hal/hal_uart.h"
|
||||
|
||||
static byte *g_recvBuf = 0;
|
||||
static int g_recvBufSize = 0;
|
||||
@ -158,114 +57,11 @@ void UART_AppendByteToReceiveRingBuffer(int rc) {
|
||||
}
|
||||
}
|
||||
|
||||
#if PLATFORM_BK7231T | PLATFORM_BK7231N
|
||||
void test_ty_read_uart_data_to_buffer(int port, void* param)
|
||||
void UART_SendByte(byte b)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
while((rc = uart_read_byte(port)) != -1)
|
||||
UART_AppendByteToReceiveRingBuffer(rc);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_BL602
|
||||
//void UART_RunQuickTick() {
|
||||
//}
|
||||
//void MY_UART1_IRQHandler(void)
|
||||
//{
|
||||
// int length;
|
||||
// byte buffer[16];
|
||||
// //length = aos_read(g_fd, buffer, 1);
|
||||
// //if (length > 0) {
|
||||
// // UART_AppendByteToReceiveRingBuffer(buffer[0]);
|
||||
// //}
|
||||
// int res = bl_uart_data_recv(g_id);
|
||||
// if (res >= 0) {
|
||||
// addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "UART received: %i\n", res);
|
||||
// UART_AppendByteToReceiveRingBuffer(res);
|
||||
// }
|
||||
//}
|
||||
|
||||
static void console_cb_read(int fd, void *param)
|
||||
{
|
||||
char buffer[64]; /* adapt to usb cdc since usb fifo is 64 bytes */
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ret = aos_read(fd, buffer, sizeof(buffer));
|
||||
if (ret > 0) {
|
||||
if (ret < sizeof(buffer)) {
|
||||
fd_console = fd;
|
||||
buffer[ret] = 0;
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "BL602 received: %s\n", buffer);
|
||||
for (i = 0; i < ret; i++) {
|
||||
UART_AppendByteToReceiveRingBuffer(buffer[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("-------------BUG from aos_read for ret\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_ESPIDF
|
||||
|
||||
static void uart_event_task(void* pvParameters)
|
||||
{
|
||||
uart_event_t event;
|
||||
for(;;)
|
||||
{
|
||||
if(xQueueReceive(uart_queue, (void*)&event, (TickType_t)portMAX_DELAY))
|
||||
{
|
||||
bzero(data, 256);
|
||||
switch(event.type)
|
||||
{
|
||||
case UART_DATA:
|
||||
uart_read_bytes(uartnum, data, event.size, portMAX_DELAY);
|
||||
for(int i = 0; i < event.size; i++)
|
||||
{
|
||||
UART_AppendByteToReceiveRingBuffer(data[i]);
|
||||
vTaskDelay(3);
|
||||
}
|
||||
break;
|
||||
case UART_BUFFER_FULL:
|
||||
case UART_FIFO_OVF:
|
||||
addLogAdv(LOG_WARN, LOG_FEATURE_CMD, "%s", event.type == UART_BUFFER_FULL ? "UART_BUFFER_FULL" : "UART_FIFO_OVF");
|
||||
uart_flush_input(uartnum);
|
||||
xQueueReset(uart_queue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
data = NULL;
|
||||
vTaskDelete(NULL);
|
||||
HAL_UART_SendByte(b);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void UART_SendByte(byte b) {
|
||||
#if PLATFORM_BK7231T | PLATFORM_BK7231N
|
||||
// BK_UART_1 is defined to 0
|
||||
bk_send_byte(g_chosenUART, b);
|
||||
#elif WINDOWS
|
||||
void SIM_AppendUARTByte(byte b);
|
||||
// STUB - for testing
|
||||
SIM_AppendUARTByte(b);
|
||||
#if 1
|
||||
printf("%02X", b);
|
||||
#endif
|
||||
//addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU,"%02X", b);
|
||||
#elif PLATFORM_BL602
|
||||
aos_write(fd_console, &b, 1);
|
||||
//bl_uart_data_send(g_id, b);
|
||||
#elif PLATFORM_ESPIDF
|
||||
uart_write_bytes(uartnum, &b, 1);
|
||||
#endif
|
||||
}
|
||||
commandResult_t CMD_UART_Send_Hex(const void *context, const char *cmd, const char *args, int cmdFlags) {
|
||||
if (!(*args)) {
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU, "CMD_UART_Send_Hex: requires 1 argument (hex string, like FFAABB00CCDD\n");
|
||||
@ -339,107 +135,15 @@ commandResult_t CMD_UART_Send_ASCII(const void *context, const char *cmd, const
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
|
||||
void UART_ResetForSimulator() {
|
||||
void UART_ResetForSimulator()
|
||||
{
|
||||
g_uart_init_counter = 0;
|
||||
}
|
||||
|
||||
int UART_InitUART(int baud, int parity)
|
||||
{
|
||||
g_uart_init_counter++;
|
||||
#if PLATFORM_BK7231T | PLATFORM_BK7231N
|
||||
bk_uart_config_t config;
|
||||
|
||||
config.baud_rate = baud;
|
||||
config.data_width = 0x03;
|
||||
config.parity = parity; //0:no parity,1:odd,2:even
|
||||
config.stop_bits = 0; //0:1bit,1:2bit
|
||||
config.flow_control = 0; //FLOW_CTRL_DISABLED
|
||||
config.flags = 0;
|
||||
|
||||
|
||||
// BK_UART_1 is defined to 0
|
||||
if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART))
|
||||
{
|
||||
g_chosenUART = BK_UART_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_chosenUART = BK_UART_1;
|
||||
}
|
||||
bk_uart_initialize(g_chosenUART, &config, NULL);
|
||||
bk_uart_set_rx_callback(g_chosenUART, test_ty_read_uart_data_to_buffer, NULL);
|
||||
#elif PLATFORM_BL602
|
||||
if(fd_console < 0)
|
||||
{
|
||||
//uint8_t tx_pin = 16;
|
||||
//uint8_t rx_pin = 7;
|
||||
//bl_uart_init(g_id, tx_pin, rx_pin, 0, 0, baud);
|
||||
//g_fd = aos_open(name, 0);
|
||||
//bl_uart_int_rx_enable(1);
|
||||
//bl_irq_register(UART1_IRQn, MY_UART1_IRQHandler);
|
||||
//bl_irq_enable(UART1_IRQn);
|
||||
//vfs_uart_init_simple_mode(0, 7, 16, baud, "/dev/ttyS0");
|
||||
|
||||
if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART))
|
||||
{
|
||||
fd_console = aos_open("/dev/ttyS1", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd_console = aos_open("/dev/ttyS0", 0);
|
||||
}
|
||||
if(fd_console >= 0)
|
||||
{
|
||||
aos_ioctl(fd_console, IOCTL_UART_IOC_BAUD_MODE, baud);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "Init CLI with event Driven\r\n");
|
||||
aos_cli_init(0);
|
||||
aos_poll_read_fd(fd_console, console_cb_read, (void*)0x12345678);
|
||||
}
|
||||
else
|
||||
{
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "failed CLI with event Driven\r\n");
|
||||
}
|
||||
}
|
||||
#elif PLATFORM_ESPIDF
|
||||
if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART))
|
||||
{
|
||||
uartnum = UART_NUM_1;
|
||||
esp_log_level_set("*", ESP_LOG_INFO);
|
||||
}
|
||||
else
|
||||
{
|
||||
uartnum = UART_NUM_0;
|
||||
esp_log_level_set("*", ESP_LOG_NONE);
|
||||
}
|
||||
if(uart_is_driver_installed(uartnum))
|
||||
{
|
||||
uart_driver_delete(uartnum);
|
||||
}
|
||||
uart_config_t uart_config =
|
||||
{
|
||||
.baud_rate = baud,
|
||||
.data_bits = UART_DATA_8_BITS,
|
||||
.parity = parity > 0 ? parity + 1 : parity,
|
||||
.stop_bits = UART_STOP_BITS_1,
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||
.source_clk = UART_SCLK_DEFAULT,
|
||||
};
|
||||
uart_driver_install(uartnum, 256, 0, 20, &uart_queue, 0);
|
||||
uart_param_config(uartnum, &uart_config);
|
||||
if(uartnum == UART_NUM_0)
|
||||
{
|
||||
uart_set_pin(uartnum, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_set_pin(uartnum, TX1_PIN, RX1_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||
}
|
||||
if(data == NULL)
|
||||
{
|
||||
data = (uint8_t*)malloc(256);
|
||||
xTaskCreate(uart_event_task, "uart_event_task", 1024, NULL, 16, NULL);
|
||||
}
|
||||
#endif
|
||||
HAL_UART_Init(baud, parity);
|
||||
return g_uart_init_counter;
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,29 @@
|
||||
|
||||
#include "../../new_common.h"
|
||||
#include "../hal_generic.h"
|
||||
#include <BkDriverWdg.h>
|
||||
|
||||
// from wlan_ui.c
|
||||
void bk_reboot(void);
|
||||
extern bool g_powersave;
|
||||
|
||||
void HAL_RebootModule() {
|
||||
void HAL_RebootModule()
|
||||
{
|
||||
bk_reboot();
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_Delay_us(int delay)
|
||||
{
|
||||
float adj = 1;
|
||||
if(g_powersave) adj = 1.5;
|
||||
usleep((17 * delay * adj) / 10); // "1" is to fast and "2" to slow, 1.7 seems better than 1.5 (only from observing readings, no scope involved)
|
||||
}
|
||||
|
||||
void HAL_Configure_WDT()
|
||||
{
|
||||
bk_wdg_initialize(10000);
|
||||
}
|
||||
|
||||
void HAL_Run_WDT()
|
||||
{
|
||||
bk_wdg_reload();
|
||||
}
|
||||
|
||||
51
src/hal/bk7231/hal_uart_bk7231.c
Normal file
51
src/hal/bk7231/hal_uart_bk7231.c
Normal file
@ -0,0 +1,51 @@
|
||||
#include "../hal_uart.h"
|
||||
#include "../../new_pins.h"
|
||||
#include "../../new_cfg.h"
|
||||
#include "../../cmnds/cmd_public.h"
|
||||
#include "../../cmnds/cmd_local.h"
|
||||
#include "../../logging/logging.h"
|
||||
#include "../../../beken378/func/user_driver/BkDriverUart.h"
|
||||
|
||||
// from uart_bk.c
|
||||
extern void bk_send_byte(UINT8 uport, UINT8 data);
|
||||
int g_chosenUART = BK_UART_1;
|
||||
|
||||
void test_ty_read_uart_data_to_buffer(int port, void* param)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
while((rc = uart_read_byte(port)) != -1)
|
||||
UART_AppendByteToReceiveRingBuffer(rc);
|
||||
}
|
||||
|
||||
void HAL_UART_SendByte(byte b)
|
||||
{
|
||||
// BK_UART_1 is defined to 0
|
||||
bk_send_byte(g_chosenUART, b);
|
||||
}
|
||||
|
||||
int HAL_UART_Init(int baud, int parity)
|
||||
{
|
||||
bk_uart_config_t config;
|
||||
|
||||
config.baud_rate = baud;
|
||||
config.data_width = 0x03;
|
||||
config.parity = parity; //0:no parity,1:odd,2:even
|
||||
config.stop_bits = 0; //0:1bit,1:2bit
|
||||
config.flow_control = 0; //FLOW_CTRL_DISABLED
|
||||
config.flags = 0;
|
||||
|
||||
|
||||
// BK_UART_1 is defined to 0
|
||||
if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART))
|
||||
{
|
||||
g_chosenUART = BK_UART_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_chosenUART = BK_UART_1;
|
||||
}
|
||||
bk_uart_initialize(g_chosenUART, &config, NULL);
|
||||
bk_uart_set_rx_callback(g_chosenUART, test_ty_read_uart_data_to_buffer, NULL);
|
||||
return 1;
|
||||
}
|
||||
@ -1,12 +1,43 @@
|
||||
#ifdef PLATFORM_BL602
|
||||
|
||||
#include "../hal_generic.h"
|
||||
#include "../../new_common.h"
|
||||
#include <hal_sys.h>
|
||||
#include <bl_wdt.h>
|
||||
|
||||
void HAL_RebootModule() {
|
||||
|
||||
void HAL_RebootModule()
|
||||
{
|
||||
hal_reboot();
|
||||
|
||||
}
|
||||
|
||||
#endif // PLATFORM_XR809
|
||||
void HAL_Delay_us(int delay)
|
||||
{
|
||||
for(volatile int i = 0; i < delay; i++)
|
||||
{
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); // 5
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); //10
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_Configure_WDT()
|
||||
{
|
||||
bl_wdt_init(3000);
|
||||
}
|
||||
|
||||
void HAL_Run_WDT()
|
||||
{
|
||||
bl_wdt_feed();
|
||||
}
|
||||
|
||||
#endif // PLATFORM_BL602
|
||||
|
||||
166
src/hal/bl602/hal_uart_bl602.c
Normal file
166
src/hal/bl602/hal_uart_bl602.c
Normal file
@ -0,0 +1,166 @@
|
||||
#ifdef PLATFORM_BL602
|
||||
|
||||
#include "../../new_pins.h"
|
||||
#include "../../new_cfg.h"
|
||||
#include "../../cmnds/cmd_public.h"
|
||||
#include "../../cmnds/cmd_local.h"
|
||||
#include "../../logging/logging.h"
|
||||
|
||||
#include "../hal_uart.h"
|
||||
#include <vfs.h>
|
||||
#include <bl_uart.h>
|
||||
#include <bl_irq.h>
|
||||
#include <event_device.h>
|
||||
#include <cli.h>
|
||||
#include <aos/kernel.h>
|
||||
#include <aos/yloop.h>
|
||||
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <timers.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <vfs.h>
|
||||
#include <aos/kernel.h>
|
||||
#include <aos/yloop.h>
|
||||
#include <event_device.h>
|
||||
#include <cli.h>
|
||||
|
||||
#include <lwip/tcpip.h>
|
||||
#include <lwip/sockets.h>
|
||||
#include <lwip/netdb.h>
|
||||
#include <lwip/tcp.h>
|
||||
#include <lwip/err.h>
|
||||
#include <http_client.h>
|
||||
#include <netutils/netutils.h>
|
||||
|
||||
#include <bl602_glb.h>
|
||||
#include <bl602_hbn.h>
|
||||
|
||||
#include <bl_uart.h>
|
||||
#include <bl_chip.h>
|
||||
#include <bl_wifi.h>
|
||||
#include <hal_wifi.h>
|
||||
#include <bl_sec.h>
|
||||
#include <bl_cks.h>
|
||||
#include <bl_irq.h>
|
||||
#include <bl_dma.h>
|
||||
#include <bl_timer.h>
|
||||
#include <bl_gpio_cli.h>
|
||||
#include <bl_wdt_cli.h>
|
||||
#include <hal_uart.h>
|
||||
#include <hal_sys.h>
|
||||
#include <hal_gpio.h>
|
||||
#include <hal_boot2.h>
|
||||
#include <hal_board.h>
|
||||
#include <looprt.h>
|
||||
#include <loopset.h>
|
||||
#include <sntp.h>
|
||||
#include <bl_sys_time.h>
|
||||
#include <bl_sys.h>
|
||||
#include <bl_sys_ota.h>
|
||||
#include <bl_romfs.h>
|
||||
#include <fdt.h>
|
||||
#include <device/vfs_uart.h>
|
||||
#include <utils_log.h>
|
||||
#include <bl602_uart.h>
|
||||
|
||||
#include <easyflash.h>
|
||||
#include <bl60x_fw_api.h>
|
||||
#include <wifi_mgmr_ext.h>
|
||||
#include <utils_log.h>
|
||||
#include <libfdt.h>
|
||||
#include <blog.h>
|
||||
|
||||
//int g_fd;
|
||||
uint8_t g_id = 1;
|
||||
int fd_console = -1;
|
||||
|
||||
//void UART_RunQuickTick() {
|
||||
//}
|
||||
//void MY_UART1_IRQHandler(void)
|
||||
//{
|
||||
// int length;
|
||||
// byte buffer[16];
|
||||
// //length = aos_read(g_fd, buffer, 1);
|
||||
// //if (length > 0) {
|
||||
// // UART_AppendByteToReceiveRingBuffer(buffer[0]);
|
||||
// //}
|
||||
// int res = bl_uart_data_recv(g_id);
|
||||
// if (res >= 0) {
|
||||
// addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "UART received: %i\n", res);
|
||||
// UART_AppendByteToReceiveRingBuffer(res);
|
||||
// }
|
||||
//}
|
||||
|
||||
static void console_cb_read(int fd, void* param)
|
||||
{
|
||||
char buffer[64]; /* adapt to usb cdc since usb fifo is 64 bytes */
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ret = aos_read(fd, buffer, sizeof(buffer));
|
||||
if(ret > 0)
|
||||
{
|
||||
if(ret < sizeof(buffer))
|
||||
{
|
||||
fd_console = fd;
|
||||
buffer[ret] = 0;
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "BL602 received: %s\n", buffer);
|
||||
for(i = 0; i < ret; i++)
|
||||
{
|
||||
UART_AppendByteToReceiveRingBuffer(buffer[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("-------------BUG from aos_read for ret\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_UART_SendByte(byte b)
|
||||
{
|
||||
aos_write(fd_console, &b, 1);
|
||||
//bl_uart_data_send(g_id, b);
|
||||
}
|
||||
|
||||
int HAL_UART_Init(int baud, int parity)
|
||||
{
|
||||
if(fd_console < 0)
|
||||
{
|
||||
//uint8_t tx_pin = 16;
|
||||
//uint8_t rx_pin = 7;
|
||||
//bl_uart_init(g_id, tx_pin, rx_pin, 0, 0, baud);
|
||||
//g_fd = aos_open(name, 0);
|
||||
//bl_uart_int_rx_enable(1);
|
||||
//bl_irq_register(UART1_IRQn, MY_UART1_IRQHandler);
|
||||
//bl_irq_enable(UART1_IRQn);
|
||||
//vfs_uart_init_simple_mode(0, 7, 16, baud, "/dev/ttyS0");
|
||||
|
||||
if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART))
|
||||
{
|
||||
fd_console = aos_open("/dev/ttyS1", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
fd_console = aos_open("/dev/ttyS0", 0);
|
||||
}
|
||||
if(fd_console >= 0)
|
||||
{
|
||||
aos_ioctl(fd_console, IOCTL_UART_IOC_BAUD_MODE, baud);
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "Init CLI with event Driven\r\n");
|
||||
aos_cli_init(0);
|
||||
aos_poll_read_fd(fd_console, console_cb_read, (void*)0x12345678);
|
||||
}
|
||||
else
|
||||
{
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_ENERGYMETER, "failed CLI with event Driven\r\n");
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,8 +1,11 @@
|
||||
#ifdef PLATFORM_ESPIDF
|
||||
|
||||
#include <unistd.h>
|
||||
#include "../hal_generic.h"
|
||||
#include "esp_system.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
static int bFlashReady = 0;
|
||||
|
||||
@ -27,4 +30,9 @@ void HAL_RebootModule()
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
void HAL_Delay_us(int delay)
|
||||
{
|
||||
usleep(delay);
|
||||
}
|
||||
|
||||
#endif // PLATFORM_ESPIDF
|
||||
|
||||
110
src/hal/espidf/hal_uart_espidf.c
Normal file
110
src/hal/espidf/hal_uart_espidf.c
Normal file
@ -0,0 +1,110 @@
|
||||
#ifdef PLATFORM_ESPIDF
|
||||
|
||||
#include "../hal_uart.h"
|
||||
#include "../../new_pins.h"
|
||||
#include "../../new_cfg.h"
|
||||
#include "../../cmnds/cmd_public.h"
|
||||
#include "../../cmnds/cmd_local.h"
|
||||
#include "../../logging/logging.h"
|
||||
#include "driver/uart.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32C6
|
||||
#define RX1_PIN GPIO_NUM_7
|
||||
#define TX1_PIN GPIO_NUM_5
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2
|
||||
#define RX1_PIN GPIO_NUM_6
|
||||
#define TX1_PIN GPIO_NUM_7
|
||||
#else
|
||||
#define RX1_PIN UART_PIN_NO_CHANGE
|
||||
#define TX1_PIN UART_PIN_NO_CHANGE
|
||||
#endif
|
||||
|
||||
uart_port_t uartnum = UART_NUM_0;
|
||||
static QueueHandle_t uart_queue;
|
||||
uint8_t* data = NULL;
|
||||
|
||||
static void uart_event_task(void* pvParameters)
|
||||
{
|
||||
uart_event_t event;
|
||||
for(;;)
|
||||
{
|
||||
if(xQueueReceive(uart_queue, (void*)&event, (TickType_t)portMAX_DELAY))
|
||||
{
|
||||
bzero(data, 512);
|
||||
switch(event.type)
|
||||
{
|
||||
case UART_DATA:
|
||||
uart_read_bytes(uartnum, data, event.size, portMAX_DELAY);
|
||||
for(int i = 0; i < event.size; i++)
|
||||
{
|
||||
UART_AppendByteToReceiveRingBuffer(data[i]);
|
||||
}
|
||||
break;
|
||||
case UART_BUFFER_FULL:
|
||||
case UART_FIFO_OVF:
|
||||
addLogAdv(LOG_WARN, LOG_FEATURE_CMD, "%s", event.type == UART_BUFFER_FULL ? "UART_BUFFER_FULL" : "UART_FIFO_OVF");
|
||||
uart_flush_input(uartnum);
|
||||
xQueueReset(uart_queue);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
data = NULL;
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void HAL_UART_SendByte(byte b)
|
||||
{
|
||||
uart_write_bytes(uartnum, &b, 1);
|
||||
}
|
||||
|
||||
int HAL_UART_Init(int baud, int parity)
|
||||
{
|
||||
if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART))
|
||||
{
|
||||
uartnum = UART_NUM_1;
|
||||
esp_log_level_set("*", ESP_LOG_INFO);
|
||||
}
|
||||
else
|
||||
{
|
||||
uartnum = UART_NUM_0;
|
||||
esp_log_level_set("*", ESP_LOG_NONE);
|
||||
}
|
||||
if(uart_is_driver_installed(uartnum))
|
||||
{
|
||||
uart_disable_rx_intr(uartnum);
|
||||
uart_driver_delete(uartnum);
|
||||
}
|
||||
uart_config_t uart_config =
|
||||
{
|
||||
.baud_rate = baud,
|
||||
.data_bits = UART_DATA_8_BITS,
|
||||
.parity = parity > 0 ? parity + 1 : parity,
|
||||
.stop_bits = UART_STOP_BITS_1,
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||
.source_clk = UART_SCLK_DEFAULT,
|
||||
};
|
||||
uart_driver_install(uartnum, 512, 0, 20, &uart_queue, 0);
|
||||
uart_param_config(uartnum, &uart_config);
|
||||
if(uartnum == UART_NUM_0)
|
||||
{
|
||||
uart_set_pin(uartnum, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_set_pin(uartnum, TX1_PIN, RX1_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||
}
|
||||
if(data == NULL)
|
||||
{
|
||||
data = (uint8_t*)malloc(512);
|
||||
xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, 16, NULL);
|
||||
uart_enable_rx_intr(uartnum);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
11
src/hal/generic/hal_adc_generic.c
Normal file
11
src/hal/generic/hal_adc_generic.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "../hal_adc.h"
|
||||
|
||||
void __attribute__((weak)) HAL_ADC_Init(int pinNumber)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_ADC_Read(int pinNumber)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
11
src/hal/generic/hal_flashConfig_generic.c
Normal file
11
src/hal/generic/hal_flashConfig_generic.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "../hal_flashConfig.h"
|
||||
|
||||
int __attribute__((weak)) HAL_Configuration_ReadConfigMemory(void* target, int dataLen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_Configuration_SaveConfigMemory(void* src, int dataLen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
72
src/hal/generic/hal_flashVars_generic.c
Normal file
72
src/hal/generic/hal_flashVars_generic.c
Normal file
@ -0,0 +1,72 @@
|
||||
#include "../../new_common.h"
|
||||
#include "../hal_flashVars.h"
|
||||
#include "../../logging/logging.h"
|
||||
|
||||
// call at startup
|
||||
void __attribute__((weak)) HAL_FlashVars_IncreaseBootCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_FlashVars_SaveChannel(int index, int value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_FlashVars_ReadLED(byte* mode, short* brightness, short* temperature, byte* rgb, byte* bEnableAll)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_FlashVars_SaveLED(byte mode, short brightness, short temperature, byte r, byte g, byte b, byte bEnableAll)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
short __attribute__((weak)) HAL_FlashVars_ReadUsage()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_FlashVars_SaveTotalUsage(short usage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// call once started (>30s?)
|
||||
void __attribute__((weak)) HAL_FlashVars_SaveBootComplete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// call to return the number of boots since a HAL_FlashVars_SaveBootComplete
|
||||
int __attribute__((weak)) HAL_FlashVars_GetBootFailures()
|
||||
{
|
||||
int diff = 0;
|
||||
return diff;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_FlashVars_GetBootCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_FlashVars_GetChannelValue(int ch)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_GetEnergyMeterStatus(ENERGY_METERING_DATA* data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_SetEnergyMeterStatus(ENERGY_METERING_DATA* data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_FlashVars_SaveTotalConsumption(float total_consumption)
|
||||
{
|
||||
|
||||
}
|
||||
26
src/hal/generic/hal_generic.c
Normal file
26
src/hal/generic/hal_generic.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include "../hal_generic.h"
|
||||
|
||||
void __attribute__((weak)) HAL_RebootModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_Delay_us(int delay)
|
||||
{
|
||||
for(volatile int i = 0; i < delay; i++)
|
||||
{
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
}
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_Configure_WDT()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_Run_WDT()
|
||||
{
|
||||
|
||||
}
|
||||
3
src/hal/generic/hal_main_generic.c
Normal file
3
src/hal/generic/hal_main_generic.c
Normal file
@ -0,0 +1,3 @@
|
||||
#include "../../new_common.h"
|
||||
#include "../../logging/logging.h"
|
||||
#include "../../quicktick.h"
|
||||
70
src/hal/generic/hal_pins_generic.c
Normal file
70
src/hal/generic/hal_pins_generic.c
Normal file
@ -0,0 +1,70 @@
|
||||
#include "../../new_common.h"
|
||||
#include "../../logging/logging.h"
|
||||
#include "../../new_cfg.h"
|
||||
#include "../../new_pins.h"
|
||||
|
||||
|
||||
int __attribute__((weak)) PIN_GetPWMIndexForPinIndex(int pin)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* __attribute__((weak)) HAL_PIN_GetPinNameAlias(int index)
|
||||
{
|
||||
return "error";
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_PIN_CanThisPinBePWM(int index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PIN_SetOutputValue(int index, int iVal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_PIN_ReadDigitalInput(int index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PIN_Setup_Input_Pullup(int index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PIN_Setup_Input_Pulldown(int index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PIN_Setup_Input(int index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PIN_Setup_Output(int index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PIN_PWM_Stop(int index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PIN_PWM_Start(int index)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PIN_PWM_Update(int index, float value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int __attribute__((weak)) HAL_GetGPIOPin(int index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
11
src/hal/generic/hal_uart_generic.c
Normal file
11
src/hal/generic/hal_uart_generic.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "../hal_uart.h"
|
||||
|
||||
void __attribute__((weak)) HAL_UART_SendByte(byte b)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_UART_Init(int baud, int parity)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
68
src/hal/generic/hal_wifi_generic.c
Normal file
68
src/hal/generic/hal_wifi_generic.c
Normal file
@ -0,0 +1,68 @@
|
||||
#include "../hal_wifi.h"
|
||||
#include "../../new_common.h"
|
||||
|
||||
const char* __attribute__((weak)) HAL_GetMyIPString()
|
||||
{
|
||||
return "error";
|
||||
}
|
||||
|
||||
const char* __attribute__((weak)) HAL_GetMyGatewayString()
|
||||
{
|
||||
return "error";
|
||||
}
|
||||
|
||||
const char* __attribute__((weak)) HAL_GetMyDNSString()
|
||||
{
|
||||
return "error";
|
||||
}
|
||||
|
||||
const char* __attribute__((weak)) HAL_GetMyMaskString()
|
||||
{
|
||||
return "error";;
|
||||
}
|
||||
|
||||
int __attribute__((weak)) WiFI_SetMacAddress(char* mac)
|
||||
{
|
||||
|
||||
return 0; // error
|
||||
}
|
||||
|
||||
void __attribute__((weak)) WiFI_GetMacAddress(char* mac)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const char* __attribute__((weak)) HAL_GetMACStr(char* macstr)
|
||||
{
|
||||
return "error";
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_PrintNetworkInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_GetWifiStrength()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_WiFi_SetupStatusCallback(void (*cb)(int code))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_ConnectToWiFi(const char* oob_ssid, const char* connect_key, obkStaticIP_t* ip)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void __attribute__((weak)) HAL_DisconnectFromWifi()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int __attribute__((weak)) HAL_SetupWiFiOpenAccessPoint(const char* ssid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -1,2 +1,5 @@
|
||||
|
||||
void HAL_RebootModule();
|
||||
void HAL_Delay_us(int delay);
|
||||
void HAL_Configure_WDT();
|
||||
void HAL_Run_WDT();
|
||||
|
||||
6
src/hal/hal_uart.h
Normal file
6
src/hal/hal_uart.h
Normal file
@ -0,0 +1,6 @@
|
||||
#include "../new_common.h"
|
||||
#include "../driver/drv_uart.h"
|
||||
|
||||
void HAL_UART_SendByte(byte b);
|
||||
|
||||
int HAL_UART_Init(int baud, int parity);
|
||||
@ -1,9 +1,41 @@
|
||||
#ifdef PLATFORM_LN882H
|
||||
|
||||
#include "hal/hal_wdt.h"
|
||||
#include "utils/reboot_trace/reboot_trace.h"
|
||||
|
||||
void HAL_RebootModule() {
|
||||
ln_chip_reboot();
|
||||
extern void ln_block_delayus(uint32_t us);
|
||||
|
||||
void HAL_RebootModule()
|
||||
{
|
||||
ln_chip_reboot();
|
||||
}
|
||||
|
||||
#endif // PLATFORM_LN882H
|
||||
void HAL_Configure_WDT()
|
||||
{
|
||||
/* Watchdog initialization */
|
||||
wdt_init_t_def wdt_init;
|
||||
memset(&wdt_init, 0, sizeof(wdt_init));
|
||||
wdt_init.wdt_rmod = WDT_RMOD_1; // When equal to 0, the counter is reset directly when it overflows; when equal to 1, an interrupt is generated first when the counter overflows, and if it overflows again, it resets.
|
||||
wdt_init.wdt_rpl = WDT_RPL_32_PCLK; // Set the reset delay time
|
||||
wdt_init.top = WDT_TOP_VALUE_9; //wdt cnt value = 0x1FFFF Time = 4.095 s
|
||||
hal_wdt_init(WDT_BASE, &wdt_init);
|
||||
|
||||
/* Configure watchdog interrupt */
|
||||
NVIC_SetPriority(WDT_IRQn, 4);
|
||||
NVIC_EnableIRQ(WDT_IRQn);
|
||||
|
||||
/* Enable watchdog */
|
||||
hal_wdt_en(WDT_BASE, HAL_ENABLE);
|
||||
}
|
||||
|
||||
void HAL_Run_WDT()
|
||||
{
|
||||
hal_wdt_cnt_restart(WDT_BASE);
|
||||
}
|
||||
|
||||
void HAL_Delay_us(int delay)
|
||||
{
|
||||
ln_block_delayus(delay);
|
||||
}
|
||||
|
||||
#endif // PLATFORM_LN882H
|
||||
|
||||
29
src/hal/rtl87x0c/hal_flashConfig_rtl87x0c.c
Normal file
29
src/hal/rtl87x0c/hal_flashConfig_rtl87x0c.c
Normal file
@ -0,0 +1,29 @@
|
||||
#ifdef PLATFORM_RTL87X0C
|
||||
|
||||
#include "../hal_flashConfig.h"
|
||||
#include <easyflash.h>
|
||||
|
||||
static int g_easyFlash_Ready = 0;
|
||||
void InitEasyFlashIfNeeded()
|
||||
{
|
||||
if(g_easyFlash_Ready == 0)
|
||||
{
|
||||
easyflash_init();
|
||||
g_easyFlash_Ready = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int HAL_Configuration_ReadConfigMemory(void* target, int dataLen)
|
||||
{
|
||||
InitEasyFlashIfNeeded();
|
||||
return ef_get_env_blob("ObkCfg", target, dataLen, NULL);
|
||||
}
|
||||
|
||||
int HAL_Configuration_SaveConfigMemory(void* src, int dataLen)
|
||||
{
|
||||
InitEasyFlashIfNeeded();
|
||||
ef_set_env_blob("ObkCfg", src, dataLen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // PLATFORM_RTL87X0C
|
||||
182
src/hal/rtl87x0c/hal_flashVars_rtl87x0c.c
Normal file
182
src/hal/rtl87x0c/hal_flashVars_rtl87x0c.c
Normal file
@ -0,0 +1,182 @@
|
||||
#ifdef PLATFORM_RTL87X0C
|
||||
|
||||
#include "../../new_common.h"
|
||||
#include "../hal_flashVars.h"
|
||||
#include "../../logging/logging.h"
|
||||
#include <easyflash.h>
|
||||
|
||||
FLASH_VARS_STRUCTURE flash_vars;
|
||||
static int g_loaded = 0;
|
||||
|
||||
#define KV_KEY_FLASH_VARS "OBK_FV"
|
||||
#define SAVE_CHANGE_IF_REQUIRED_AND_COUNT(target, source, counter) \
|
||||
if((target) != (source)) { \
|
||||
(target) = (source); \
|
||||
counter++; \
|
||||
}
|
||||
|
||||
extern void InitEasyFlashIfNeeded();
|
||||
|
||||
static int ReadFlashVars(void* target, int dataLen)
|
||||
{
|
||||
InitEasyFlashIfNeeded();
|
||||
int readLen;
|
||||
ADDLOG_DEBUG(LOG_FEATURE_CFG, "ReadFlashVars: will read %d bytes", dataLen);
|
||||
readLen = ef_get_env_blob(KV_KEY_FLASH_VARS, target, dataLen, NULL);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_CFG, "ReadFlashVars: really loaded %d bytes", readLen);
|
||||
g_loaded = 1;
|
||||
return dataLen;
|
||||
}
|
||||
|
||||
static int SaveFlashVars(void* src, int dataLen)
|
||||
{
|
||||
InitEasyFlashIfNeeded();
|
||||
EfErrCode res;
|
||||
|
||||
res = ef_set_env_blob(KV_KEY_FLASH_VARS, src, dataLen);
|
||||
if(res == EF_ENV_INIT_FAILED)
|
||||
{
|
||||
ADDLOG_DEBUG(LOG_FEATURE_CFG, "SaveFlashVars: EF_ENV_INIT_FAILED for %d bytes", dataLen);
|
||||
return 0;
|
||||
}
|
||||
if(res == EF_ENV_NAME_ERR)
|
||||
{
|
||||
ADDLOG_DEBUG(LOG_FEATURE_CFG, "SaveFlashVars: EF_ENV_ARG_ERR for %d bytes", dataLen);
|
||||
return 0;
|
||||
}
|
||||
ADDLOG_DEBUG(LOG_FEATURE_CFG, "SaveFlashVars: saved %d bytes", dataLen);
|
||||
return dataLen;
|
||||
}
|
||||
|
||||
// call at startup
|
||||
void HAL_FlashVars_IncreaseBootCount()
|
||||
{
|
||||
memset(&flash_vars, 0, sizeof(flash_vars));
|
||||
ReadFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
flash_vars.boot_count++;
|
||||
SaveFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
|
||||
void HAL_FlashVars_SaveChannel(int index, int value)
|
||||
{
|
||||
if(index < 0 || index >= MAX_RETAIN_CHANNELS)
|
||||
return;
|
||||
if(g_loaded == 0)
|
||||
{
|
||||
ReadFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
flash_vars.savedValues[index] = value;
|
||||
// save after increase
|
||||
SaveFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
|
||||
void HAL_FlashVars_ReadLED(byte* mode, short* brightness, short* temperature, byte* rgb, byte* bEnableAll)
|
||||
{
|
||||
if(g_loaded == 0)
|
||||
{
|
||||
ReadFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
*bEnableAll = flash_vars.savedValues[MAX_RETAIN_CHANNELS - 4];
|
||||
*mode = flash_vars.savedValues[MAX_RETAIN_CHANNELS - 3];
|
||||
*temperature = flash_vars.savedValues[MAX_RETAIN_CHANNELS - 2];
|
||||
*brightness = flash_vars.savedValues[MAX_RETAIN_CHANNELS - 1];
|
||||
rgb[0] = flash_vars.rgb[0];
|
||||
rgb[1] = flash_vars.rgb[1];
|
||||
rgb[2] = flash_vars.rgb[2];
|
||||
}
|
||||
|
||||
void HAL_FlashVars_SaveLED(byte mode, short brightness, short temperature, byte r, byte g, byte b, byte bEnableAll)
|
||||
{
|
||||
int iChangesCount = 0;
|
||||
|
||||
if(g_loaded == 0)
|
||||
{
|
||||
ReadFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
|
||||
SAVE_CHANGE_IF_REQUIRED_AND_COUNT(flash_vars.savedValues[MAX_RETAIN_CHANNELS - 1], brightness, iChangesCount);
|
||||
SAVE_CHANGE_IF_REQUIRED_AND_COUNT(flash_vars.savedValues[MAX_RETAIN_CHANNELS - 2], temperature, iChangesCount);
|
||||
SAVE_CHANGE_IF_REQUIRED_AND_COUNT(flash_vars.savedValues[MAX_RETAIN_CHANNELS - 3], mode, iChangesCount);
|
||||
SAVE_CHANGE_IF_REQUIRED_AND_COUNT(flash_vars.savedValues[MAX_RETAIN_CHANNELS - 4], bEnableAll, iChangesCount);
|
||||
SAVE_CHANGE_IF_REQUIRED_AND_COUNT(flash_vars.rgb[0], r, iChangesCount);
|
||||
SAVE_CHANGE_IF_REQUIRED_AND_COUNT(flash_vars.rgb[1], g, iChangesCount);
|
||||
SAVE_CHANGE_IF_REQUIRED_AND_COUNT(flash_vars.rgb[2], b, iChangesCount);
|
||||
|
||||
if(iChangesCount > 0)
|
||||
{
|
||||
ADDLOG_INFO(LOG_FEATURE_CFG, "####### Flash Save LED #######");
|
||||
SaveFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
}
|
||||
|
||||
short HAL_FlashVars_ReadUsage()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_FlashVars_SaveTotalUsage(short usage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// call once started (>30s?)
|
||||
void HAL_FlashVars_SaveBootComplete()
|
||||
{
|
||||
flash_vars.boot_success_count = flash_vars.boot_count;
|
||||
SaveFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
|
||||
// call to return the number of boots since a HAL_FlashVars_SaveBootComplete
|
||||
int HAL_FlashVars_GetBootFailures()
|
||||
{
|
||||
int diff = 0;
|
||||
diff = flash_vars.boot_count - flash_vars.boot_success_count;
|
||||
return diff;
|
||||
}
|
||||
|
||||
int HAL_FlashVars_GetBootCount()
|
||||
{
|
||||
return flash_vars.boot_count;
|
||||
}
|
||||
|
||||
int HAL_FlashVars_GetChannelValue(int ch)
|
||||
{
|
||||
if(ch < 0 || ch >= MAX_RETAIN_CHANNELS)
|
||||
return 0;
|
||||
if(g_loaded == 0)
|
||||
{
|
||||
ReadFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
return flash_vars.savedValues[ch];
|
||||
}
|
||||
|
||||
int HAL_GetEnergyMeterStatus(ENERGY_METERING_DATA* data)
|
||||
{
|
||||
if(data != NULL)
|
||||
{
|
||||
if(g_loaded == 0)
|
||||
{
|
||||
ReadFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
memcpy(data, &flash_vars.emetering, sizeof(ENERGY_METERING_DATA));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HAL_SetEnergyMeterStatus(ENERGY_METERING_DATA* data)
|
||||
{
|
||||
if(data != NULL)
|
||||
{
|
||||
memcpy(&flash_vars.emetering, data, sizeof(ENERGY_METERING_DATA));
|
||||
SaveFlashVars(&flash_vars, sizeof(flash_vars));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_FlashVars_SaveTotalConsumption(float total_consumption)
|
||||
{
|
||||
flash_vars.emetering.TotalConsumption = total_consumption;
|
||||
}
|
||||
|
||||
#endif // PLATFORM_RTL87X0C
|
||||
|
||||
29
src/hal/rtl87x0c/hal_generic_rtl87x0c.c
Normal file
29
src/hal/rtl87x0c/hal_generic_rtl87x0c.c
Normal file
@ -0,0 +1,29 @@
|
||||
#ifdef PLATFORM_RTL87X0C
|
||||
|
||||
#include "../hal_generic.h"
|
||||
#include "sys_api.h"
|
||||
#include "hal_timer.h"
|
||||
#include "hal_wdt.h"
|
||||
|
||||
void HAL_RebootModule()
|
||||
{
|
||||
sys_cpu_reset();
|
||||
}
|
||||
|
||||
void HAL_Delay_us(int delay)
|
||||
{
|
||||
hal_delay_us(delay);
|
||||
}
|
||||
|
||||
void HAL_Configure_WDT()
|
||||
{
|
||||
hal_misc_wdt_init(10 * 1000 * 1000);
|
||||
hal_misc_wdt_enable();
|
||||
}
|
||||
|
||||
void HAL_Run_WDT()
|
||||
{
|
||||
hal_misc_wdt_refresh();
|
||||
}
|
||||
|
||||
#endif // PLATFORM_RTL87X0C
|
||||
15
src/hal/rtl87x0c/hal_generic_rtl87x0c.h
Normal file
15
src/hal/rtl87x0c/hal_generic_rtl87x0c.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifdef PLATFORM_RTL87X0C
|
||||
|
||||
#include <gpio_api.h>
|
||||
#include "pwmout_api.h"
|
||||
|
||||
typedef struct rtlPinMapping_s
|
||||
{
|
||||
const char* name;
|
||||
PinName pin;
|
||||
gpio_t* gpio;
|
||||
gpio_irq_t* irq;
|
||||
pwmout_t* pwm;
|
||||
} rtlPinMapping_t;
|
||||
|
||||
#endif // PLATFORM_RTL87X0C
|
||||
178
src/hal/rtl87x0c/hal_pins_rtl87x0c.c
Normal file
178
src/hal/rtl87x0c/hal_pins_rtl87x0c.c
Normal file
@ -0,0 +1,178 @@
|
||||
#ifdef PLATFORM_RTL87X0C
|
||||
|
||||
#include "../../new_common.h"
|
||||
#include "../../logging/logging.h"
|
||||
#include "../../new_cfg.h"
|
||||
#include "../../new_pins.h"
|
||||
#include "hal_generic_rtl87x0c.h"
|
||||
|
||||
extern int g_pwmFrequency;
|
||||
|
||||
rtlPinMapping_t g_pins[] = {
|
||||
{ "PA0 (RX1)", PA_0, NULL, NULL },
|
||||
{ "PA1 (TX1)", PA_1, NULL, NULL },
|
||||
{ "PA2 (RX1)", PA_2, NULL, NULL },
|
||||
{ "PA3 (TX1)", PA_3, NULL, NULL },
|
||||
{ "PA4", PA_4, NULL, NULL },
|
||||
{ "PA5", PA_5, NULL, NULL },
|
||||
{ "PA6", PA_6, NULL, NULL },
|
||||
{ "PA7", PA_7, NULL, NULL },
|
||||
{ "PA8", PA_8, NULL, NULL },
|
||||
{ "PA9", PA_9, NULL, NULL },
|
||||
{ "PA10", PA_10, NULL, NULL },
|
||||
{ "PA11", PA_11, NULL, NULL },
|
||||
{ "PA12", PA_12, NULL, NULL },
|
||||
{ "PA13 (RX0)", PA_13, NULL, NULL },
|
||||
{ "PA14 (TX0)", PA_14, NULL, NULL },
|
||||
{ "PA15 (RX2)", PA_15, NULL, NULL },
|
||||
{ "PA16 (TX2)", PA_16, NULL, NULL },
|
||||
{ "PA17", PA_17, NULL, NULL },
|
||||
{ "PA18", PA_18, NULL, NULL },
|
||||
{ "PA19", PA_19, NULL, NULL },
|
||||
{ "PA20", PA_20, NULL, NULL },
|
||||
{ "PA21", PA_21, NULL, NULL },
|
||||
{ "PA22", PA_22, NULL, NULL },
|
||||
{ "PA23", PA_23, NULL, NULL },
|
||||
};
|
||||
|
||||
static int g_numPins = sizeof(g_pins) / sizeof(g_pins[0]);
|
||||
|
||||
int PIN_GetPWMIndexForPinIndex(int pin)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* HAL_PIN_GetPinNameAlias(int index)
|
||||
{
|
||||
if(index >= g_numPins)
|
||||
return "error";
|
||||
return g_pins[index].name;
|
||||
}
|
||||
|
||||
int HAL_PIN_CanThisPinBePWM(int index)
|
||||
{
|
||||
if(index > 6 && index < 11) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RTL_GPIO_Init(rtlPinMapping_t* pin)
|
||||
{
|
||||
if(pin->gpio != NULL || pin->irq != NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pin->gpio = os_malloc(sizeof(gpio_t));
|
||||
memset(pin->gpio, 0, sizeof(gpio_t));
|
||||
gpio_init(pin->gpio, pin->pin);
|
||||
}
|
||||
|
||||
void HAL_PIN_SetOutputValue(int index, int iVal)
|
||||
{
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
if(index >= g_numPins || pin->gpio == NULL)
|
||||
return;
|
||||
gpio_write(pin->gpio, iVal ? 1 : 0);
|
||||
}
|
||||
|
||||
int HAL_PIN_ReadDigitalInput(int index)
|
||||
{
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
if(index >= g_numPins || pin->gpio == NULL)
|
||||
return 0;
|
||||
return gpio_read(pin->gpio);
|
||||
}
|
||||
|
||||
void HAL_PIN_Setup_Input_Pullup(int index)
|
||||
{
|
||||
if(index >= g_numPins)
|
||||
return;
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
RTL_GPIO_Init(pin);
|
||||
if(pin->gpio == NULL)
|
||||
return;
|
||||
gpio_dir(pin->gpio, PIN_INPUT);
|
||||
gpio_mode(pin->gpio, PullUp);
|
||||
}
|
||||
|
||||
void HAL_PIN_Setup_Input_Pulldown(int index)
|
||||
{
|
||||
if(index >= g_numPins)
|
||||
return;
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
RTL_GPIO_Init(pin);
|
||||
if(pin->gpio == NULL)
|
||||
return;
|
||||
gpio_dir(pin->gpio, PIN_INPUT);
|
||||
gpio_mode(pin->gpio, PullDown);
|
||||
}
|
||||
|
||||
void HAL_PIN_Setup_Input(int index)
|
||||
{
|
||||
if(index >= g_numPins)
|
||||
return;
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
RTL_GPIO_Init(pin);
|
||||
if(pin->gpio == NULL)
|
||||
return;
|
||||
gpio_dir(pin->gpio, PIN_INPUT);
|
||||
gpio_mode(pin->gpio, PullNone);
|
||||
}
|
||||
|
||||
void HAL_PIN_Setup_Output(int index)
|
||||
{
|
||||
if(index >= g_numPins)
|
||||
return;
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
RTL_GPIO_Init(pin);
|
||||
if(pin->gpio == NULL)
|
||||
return;
|
||||
gpio_dir(pin->gpio, PIN_OUTPUT);
|
||||
gpio_mode(pin->gpio, PullUp);
|
||||
}
|
||||
|
||||
void HAL_PIN_PWM_Stop(int index)
|
||||
{
|
||||
if(index >= g_numPins || !HAL_PIN_CanThisPinBePWM(index))
|
||||
return;
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
if(pin->pwm == NULL) return;
|
||||
//pwmout_stop(pin->pwm);
|
||||
pwmout_free(pin->pwm);
|
||||
os_free(pin->pwm);
|
||||
pin->pwm = NULL;
|
||||
}
|
||||
|
||||
void HAL_PIN_PWM_Start(int index)
|
||||
{
|
||||
if(index >= g_numPins || !HAL_PIN_CanThisPinBePWM(index))
|
||||
return;
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
if(pin->pwm != NULL) return;
|
||||
if(pin->gpio != NULL)
|
||||
{
|
||||
hal_pinmux_unregister(pin->pin, PID_GPIO);
|
||||
os_free(pin->gpio);
|
||||
pin->gpio = NULL;
|
||||
}
|
||||
pin->pwm = os_malloc(sizeof(pwmout_t));
|
||||
memset(pin->pwm, 0, sizeof(pwmout_t));
|
||||
pwmout_init(pin->pwm, pin->pin);
|
||||
pwmout_period_us(pin->pwm, g_pwmFrequency);
|
||||
pwmout_start(pin->pwm);
|
||||
}
|
||||
|
||||
void HAL_PIN_PWM_Update(int index, float value)
|
||||
{
|
||||
if(index >= g_numPins || !HAL_PIN_CanThisPinBePWM(index))
|
||||
return;
|
||||
rtlPinMapping_t* pin = g_pins + index;
|
||||
if(pin->pwm == NULL || !pin->pwm->is_init) return;
|
||||
pwmout_write(pin->pwm, value / 100);
|
||||
}
|
||||
|
||||
unsigned int HAL_GetGPIOPin(int index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
#endif // PLATFORM_RTL87X0C
|
||||
58
src/hal/rtl87x0c/hal_uart_rtl87x0c.c
Normal file
58
src/hal/rtl87x0c/hal_uart_rtl87x0c.c
Normal file
@ -0,0 +1,58 @@
|
||||
#ifdef PLATFORM_RTL87X0C
|
||||
|
||||
#include "../../new_pins.h"
|
||||
#include "../../new_cfg.h"
|
||||
#include "../hal_uart.h"
|
||||
#include "serial_api.h"
|
||||
#include "hal_uart.h"
|
||||
#define UART0_TX PA_14
|
||||
#define UART0_RX PA_13
|
||||
#define UART1_0_TX PA_3
|
||||
#define UART1_0_RX PA_2
|
||||
#define UART1_1_TX PA_1
|
||||
#define UART1_1_RX PA_0
|
||||
|
||||
serial_t sobj;
|
||||
static bool isInitialized;
|
||||
|
||||
static void uart_cb(uint32_t id, SerialIrq event)
|
||||
{
|
||||
if(event != RxIrq)
|
||||
return;
|
||||
|
||||
serial_t* obj = (void*)id;
|
||||
uint8_t c;
|
||||
while(hal_uart_rgetc(&obj->uart_adp, (char*)&c))
|
||||
{
|
||||
UART_AppendByteToReceiveRingBuffer(c);
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_UART_SendByte(byte b)
|
||||
{
|
||||
while(!hal_uart_writeable(&sobj.uart_adp));
|
||||
hal_uart_putc(&sobj.uart_adp, b);
|
||||
}
|
||||
|
||||
int HAL_UART_Init(int baud, int parity)
|
||||
{
|
||||
if(isInitialized)
|
||||
{
|
||||
serial_free(&sobj);
|
||||
}
|
||||
PinName tx = UART0_TX, rx = UART0_RX;
|
||||
if(CFG_HasFlag(OBK_FLAG_USE_SECONDARY_UART))
|
||||
{
|
||||
tx = UART1_0_TX;
|
||||
rx = UART1_0_RX;
|
||||
}
|
||||
serial_init(&sobj, tx, rx);
|
||||
serial_baud(&sobj, baud);
|
||||
serial_format(&sobj, 8, parity, 1);
|
||||
serial_irq_handler(&sobj, uart_cb, (uint32_t)&sobj);
|
||||
serial_irq_set(&sobj, RxIrq, 1);
|
||||
isInitialized = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
293
src/hal/rtl87x0c/hal_wifi_rtl87x0c.c
Normal file
293
src/hal/rtl87x0c/hal_wifi_rtl87x0c.c
Normal file
@ -0,0 +1,293 @@
|
||||
#ifdef PLATFORM_RTL87X0C
|
||||
|
||||
#include "../hal_wifi.h"
|
||||
#include "../../new_cfg.h"
|
||||
#include "../../new_cfg.h"
|
||||
#include "../../logging/logging.h"
|
||||
#include <lwip/sockets.h>
|
||||
#include <lwip/netif.h>
|
||||
#include <wifi/wifi_conf.h>
|
||||
#include <wifi/wifi_util.h>
|
||||
#include <lwip_netconf.h>
|
||||
#include "tcpip.h"
|
||||
#include <dhcp/dhcps.h>
|
||||
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char ssid[32];
|
||||
char pwd[64];
|
||||
} wifi_data_t;
|
||||
|
||||
bool g_STA_static_IP = 0;
|
||||
|
||||
static void (*g_wifiStatusCallback)(int code) = NULL;
|
||||
static int g_bOpenAccessPointMode = 0;
|
||||
static wifi_data_t wdata = { 0 };
|
||||
extern uint8_t wmac[6];
|
||||
extern bool g_powersave;
|
||||
|
||||
const char* HAL_GetMyIPString()
|
||||
{
|
||||
return ipaddr_ntoa((const ip4_addr_t*)&xnetif[g_bOpenAccessPointMode].ip_addr.addr);
|
||||
}
|
||||
|
||||
const char* HAL_GetMyGatewayString()
|
||||
{
|
||||
return ipaddr_ntoa((const ip4_addr_t*)&xnetif[g_bOpenAccessPointMode].gw.addr);
|
||||
}
|
||||
|
||||
const char* HAL_GetMyDNSString()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* HAL_GetMyMaskString()
|
||||
{
|
||||
return ipaddr_ntoa((const ip4_addr_t*)&xnetif[g_bOpenAccessPointMode].netmask.addr);
|
||||
}
|
||||
|
||||
int WiFI_SetMacAddress(char* mac)
|
||||
{
|
||||
printf("WiFI_SetMacAddress\r\n");
|
||||
return 0; // error
|
||||
}
|
||||
|
||||
void WiFI_GetMacAddress(char* mac)
|
||||
{
|
||||
memcpy(mac, (char*)wmac, sizeof(wmac));
|
||||
}
|
||||
|
||||
const char* HAL_GetMACStr(char* macstr)
|
||||
{
|
||||
unsigned char mac[6];
|
||||
WiFI_GetMacAddress((char*)mac);
|
||||
sprintf(macstr, MACSTR, MAC2STR(mac));
|
||||
return macstr;
|
||||
}
|
||||
|
||||
void HAL_PrintNetworkInfo()
|
||||
{
|
||||
uint8_t mac[6];
|
||||
WiFI_GetMacAddress((char*)mac);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "+--------------- net device info ------------+\r\n");
|
||||
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif type : %-16s |\r\n", g_bOpenAccessPointMode == 0 ? "STA" : "AP");
|
||||
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif ip = %-16s |\r\n", HAL_GetMyIPString());
|
||||
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif mask = %-16s |\r\n", HAL_GetMyMaskString());
|
||||
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif gateway = %-16s |\r\n", HAL_GetMyGatewayString());
|
||||
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "|netif mac : [%02X:%02X:%02X:%02X:%02X:%02X] %-7s |\r\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], "");
|
||||
ADDLOG_DEBUG(LOG_FEATURE_GENERAL, "+--------------------------------------------+\r\n");
|
||||
}
|
||||
|
||||
int HAL_GetWifiStrength()
|
||||
{
|
||||
int rssi;
|
||||
wext_get_rssi(WLAN0_NAME, &rssi);
|
||||
return rssi;
|
||||
}
|
||||
|
||||
void HAL_WiFi_SetupStatusCallback(void (*cb)(int code))
|
||||
{
|
||||
printf("HAL_WiFi_SetupStatusCallback\r\n");
|
||||
g_wifiStatusCallback = cb;
|
||||
}
|
||||
|
||||
static int _find_ap_from_scan_buf(char* buf, int buflen, char* target_ssid, void* user_data)
|
||||
{
|
||||
rtw_wifi_setting_t* pwifi = (rtw_wifi_setting_t*)user_data;
|
||||
int plen = 0;
|
||||
|
||||
while(plen < buflen)
|
||||
{
|
||||
u8 len, ssid_len, security_mode;
|
||||
char* ssid;
|
||||
|
||||
// len offset = 0
|
||||
len = (int)*(buf + plen);
|
||||
// check end
|
||||
if(len == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// ssid offset = 14
|
||||
ssid_len = len - 14;
|
||||
ssid = buf + plen + 14;
|
||||
if((ssid_len == strlen(target_ssid))
|
||||
&& (!memcmp(ssid, target_ssid, ssid_len)))
|
||||
{
|
||||
strncpy((char*)pwifi->ssid, target_ssid, 33);
|
||||
// channel offset = 13
|
||||
pwifi->channel = *(buf + plen + 13);
|
||||
// security_mode offset = 11
|
||||
security_mode = (u8) * (buf + plen + 11);
|
||||
if(security_mode == IW_ENCODE_ALG_NONE)
|
||||
{
|
||||
pwifi->security_type = RTW_SECURITY_OPEN;
|
||||
}
|
||||
else if(security_mode == IW_ENCODE_ALG_WEP)
|
||||
{
|
||||
pwifi->security_type = RTW_SECURITY_WEP_PSK;
|
||||
}
|
||||
else if(security_mode == IW_ENCODE_ALG_CCMP)
|
||||
{
|
||||
pwifi->security_type = RTW_SECURITY_WPA2_AES_PSK;
|
||||
}
|
||||
else if(security_mode == IW_ENCODE_ALG_OWE)
|
||||
{
|
||||
pwifi->security_type = RTW_SECURITY_WPA3_OWE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
plen += len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _get_ap_security_mode(char* ssid, rtw_security_t* security_mode, u8* channel)
|
||||
{
|
||||
rtw_wifi_setting_t wifi;
|
||||
u32 scan_buflen = 1000;
|
||||
|
||||
memset(&wifi, 0, sizeof(wifi));
|
||||
|
||||
if(wifi_scan_networks_with_ssid(_find_ap_from_scan_buf, (void*)&wifi, scan_buflen, ssid, strlen(ssid)) != RTW_SUCCESS)
|
||||
{
|
||||
printf("Wifi scan failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(strcmp((char*)wifi.ssid, ssid) == 0)
|
||||
{
|
||||
*security_mode = wifi.security_type;
|
||||
*channel = wifi.channel;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wifi_dis_hdl(u8* buf, u32 buf_len, u32 flags, void* userdata)
|
||||
{
|
||||
if(g_wifiStatusCallback != NULL)
|
||||
{
|
||||
g_wifiStatusCallback(WIFI_STA_DISCONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_con_hdl(u8* buf, u32 buf_len, u32 flags, void* userdata)
|
||||
{
|
||||
if(g_wifiStatusCallback != NULL)
|
||||
{
|
||||
g_wifiStatusCallback(WIFI_STA_CONNECTING);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_conned_hdl(u8* buf, u32 buf_len, u32 flags, void* userdata)
|
||||
{
|
||||
if(g_wifiStatusCallback != NULL)
|
||||
{
|
||||
g_wifiStatusCallback(WIFI_STA_CONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_af_hdl(u8* buf, u32 buf_len, u32 flags, void* userdata)
|
||||
{
|
||||
if(g_wifiStatusCallback != NULL)
|
||||
{
|
||||
g_wifiStatusCallback(WIFI_STA_AUTH_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectToWiFiTask(void* args)
|
||||
{
|
||||
rtw_security_t security_type = RTW_SECURITY_OPEN;
|
||||
int security_retry_count = 0;
|
||||
uint8_t connect_channel = 0;
|
||||
while(1)
|
||||
{
|
||||
if(_get_ap_security_mode(wdata.ssid, &security_type, &connect_channel))
|
||||
{
|
||||
break;
|
||||
}
|
||||
security_retry_count++;
|
||||
if(security_retry_count >= 3)
|
||||
{
|
||||
printf("Can't get AP security mode and channel.\r\n");
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
if(g_wifiStatusCallback != NULL)
|
||||
{
|
||||
g_wifiStatusCallback(WIFI_STA_CONNECTING);
|
||||
}
|
||||
int ret = wifi_connect(wdata.ssid, security_type, wdata.pwd, strlen(wdata.ssid),
|
||||
strlen(wdata.pwd), NULL, NULL);
|
||||
if(ret != RTW_SUCCESS)
|
||||
{
|
||||
printf("ERROR: Can't connect to AP\r\n");
|
||||
goto exit;
|
||||
}
|
||||
LwIP_DHCP(0, DHCP_START);
|
||||
if(wifi_is_up(RTW_STA_INTERFACE) && g_powersave) wifi_enable_powersave();
|
||||
exit:
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void HAL_ConnectToWiFi(const char* oob_ssid, const char* connect_key, obkStaticIP_t* ip)
|
||||
{
|
||||
g_bOpenAccessPointMode = 0;
|
||||
strcpy((char*)&wdata.ssid, oob_ssid);
|
||||
strcpy((char*)&wdata.pwd, connect_key);
|
||||
wifi_set_autoreconnect(0);
|
||||
|
||||
netif_set_hostname(&xnetif[0], CFG_GetDeviceName());
|
||||
wifi_reg_event_handler(WIFI_EVENT_DISCONNECT, (rtw_event_handler_t)wifi_dis_hdl, NULL);
|
||||
//wifi_reg_event_handler(WIFI_EVENT_CONNECT, (rtw_event_handler_t)wifi_con_hdl, NULL);
|
||||
wifi_reg_event_handler(WIFI_EVENT_STA_GOT_IP, (rtw_event_handler_t)wifi_conned_hdl, NULL);
|
||||
wifi_reg_event_handler(WIFI_EVENT_CHALLENGE_FAIL, (rtw_event_handler_t)wifi_af_hdl, NULL);
|
||||
|
||||
xTaskCreate(
|
||||
(TaskFunction_t)ConnectToWiFiTask,
|
||||
"WC",
|
||||
2048 / sizeof(StackType_t),
|
||||
NULL,
|
||||
5,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void HAL_DisconnectFromWifi()
|
||||
{
|
||||
printf("HAL_DisconnectFromWifi\r\n");
|
||||
if(wifi_is_connected_to_ap()) wifi_disconnect();
|
||||
}
|
||||
|
||||
int HAL_SetupWiFiOpenAccessPoint(const char* ssid)
|
||||
{
|
||||
g_bOpenAccessPointMode = 1;
|
||||
struct ip_addr ipaddr;
|
||||
struct ip_addr netmask;
|
||||
struct ip_addr gw;
|
||||
struct netif* pnetif = &xnetif[0];
|
||||
dhcps_deinit();
|
||||
wifi_off();
|
||||
vTaskDelay(20);
|
||||
if(wifi_on(RTW_MODE_AP) < 0)
|
||||
{
|
||||
printf("wifi_on failed!\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(wifi_start_ap((char*)ssid, RTW_SECURITY_OPEN, NULL, strlen(ssid), 0, 1) < 0)
|
||||
{
|
||||
printf("wifi_start_ap failed!\r\n");
|
||||
}
|
||||
IP4_ADDR(ip_2_ip4(&ipaddr), 192, 168, 4, 1);
|
||||
IP4_ADDR(ip_2_ip4(&netmask), 255, 255, 255, 0);
|
||||
IP4_ADDR(ip_2_ip4(&gw), 192, 168, 4, 1);
|
||||
netif_set_addr(pnetif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw));
|
||||
dhcps_init(pnetif);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // PLATFORM_RTL87X0C
|
||||
@ -1,8 +1,15 @@
|
||||
#ifdef PLATFORM_TR6260
|
||||
|
||||
#include "../hal_generic.h"
|
||||
|
||||
void HAL_RebootModule()
|
||||
{
|
||||
wdt_reset_chip(0);
|
||||
}
|
||||
|
||||
#endif // PLATFORM_TR6260
|
||||
void HAL_Delay_us(int delay)
|
||||
{
|
||||
usdelay(delay);
|
||||
}
|
||||
|
||||
#endif // PLATFORM_TR6260
|
||||
|
||||
@ -1,9 +1,53 @@
|
||||
#if defined(PLATFORM_W800) || defined(PLATFORM_W600)
|
||||
|
||||
#include "../hal_generic.h"
|
||||
#include "wm_include.h"
|
||||
|
||||
void HAL_RebootModule() {
|
||||
tls_sys_reset();
|
||||
void HAL_RebootModule()
|
||||
{
|
||||
tls_sys_reset();
|
||||
}
|
||||
|
||||
void HAL_Delay_us(int delay)
|
||||
{
|
||||
for(volatile int i = 0; i < delay; i++)
|
||||
{
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); // 5
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
#if PLATFORM_W800
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); //10
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); //15
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop"); //20
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
__asm__("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\nnop");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_Configure_WDT()
|
||||
{
|
||||
tls_watchdog_init(5 * 1000 * 1000);
|
||||
}
|
||||
|
||||
void HAL_Run_WDT()
|
||||
{
|
||||
tls_watchdog_clr();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,8 +1,24 @@
|
||||
#ifdef WINDOWS
|
||||
|
||||
#include "../hal_generic.h"
|
||||
|
||||
void HAL_RebootModule() {
|
||||
void HAL_RebootModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HAL_Delay_us(int delay)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HAL_Configure_WDT()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HAL_Run_WDT()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
21
src/hal/win32/hal_uart_win32.c
Normal file
21
src/hal/win32/hal_uart_win32.c
Normal file
@ -0,0 +1,21 @@
|
||||
#ifdef WINDOWS
|
||||
|
||||
#include "../hal_uart.h"
|
||||
|
||||
void HAL_UART_SendByte(byte b)
|
||||
{
|
||||
void SIM_AppendUARTByte(byte b);
|
||||
// STUB - for testing
|
||||
SIM_AppendUARTByte(b);
|
||||
#if 1
|
||||
printf("%02X", b);
|
||||
#endif
|
||||
//addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU,"%02X", b);
|
||||
}
|
||||
|
||||
int HAL_UART_Init(int baud, int parity)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -40,6 +40,10 @@ static char SUBMIT_AND_END_FORM[] = "<br><input type=\"submit\" value=\"Submit\"
|
||||
#include "temp_detect_pub.h"
|
||||
#elif defined(PLATFORM_LN882H)
|
||||
#elif defined(PLATFORM_TR6260)
|
||||
#elif defined(PLATFORM_RTL87X0C)
|
||||
#include "hal_sys_ctrl.h"
|
||||
extern hal_reset_reason_t reset_reason;
|
||||
extern uint32_t current_fw_idx;
|
||||
#elif defined(PLATFORM_ESPIDF)
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_system.h"
|
||||
@ -782,7 +786,9 @@ int http_fn_index(http_request_t* request) {
|
||||
|
||||
// display temperature - thanks to giedriuslt
|
||||
// only in Normal mode, and if boot is not failing
|
||||
#ifndef NO_CHIP_TEMPERATURE
|
||||
hprintf255(request, "<h5>Chip temperature: %.1f°C</h5>", g_wifi_temperature);
|
||||
#endif
|
||||
|
||||
inputName = CFG_GetPingHost();
|
||||
if (inputName && *inputName && CFG_GetPingDisconnectedSecondsToRestart()) {
|
||||
@ -875,6 +881,17 @@ typedef enum {
|
||||
default: break;
|
||||
}
|
||||
hprintf255(request, "<h5>Reboot reason: %i - %s</h5>", reason, s);
|
||||
#elif PLATFORM_RTL87X0C
|
||||
const char* s = "Unk";
|
||||
switch(reset_reason)
|
||||
{
|
||||
case HAL_RESET_REASON_POWER_ON: s = "Pwr"; break;
|
||||
case HAL_RESET_REASON_SOFTWARE: s = "Soft"; break;
|
||||
case HAL_RESET_REASON_WATCHDOG: s = "Wdt"; break;
|
||||
default: break;
|
||||
}
|
||||
hprintf255(request, "<h5>Reboot reason: %i - %s</h5>", reset_reason, s);
|
||||
hprintf255(request, "<h5>Current fw: FW%i</h5>", current_fw_idx);
|
||||
#endif
|
||||
if (CFG_GetMQTTHost()[0] == 0) {
|
||||
hprintf255(request, "<h5>MQTT State: not configured<br>");
|
||||
@ -1308,6 +1325,8 @@ int http_fn_cfg_wifi(http_request_t* request) {
|
||||
}
|
||||
#elif PLATFORM_TR6260
|
||||
poststr(request, "TODO TR6260<br>");
|
||||
#elif defined(PLATFORM_RTL87X0C)
|
||||
poststr(request, "TODO RTL87X0C<br>");
|
||||
#else
|
||||
#error "Unknown platform"
|
||||
poststr(request, "Unknown platform<br>");
|
||||
@ -2990,6 +3009,7 @@ void OTA_RequestDownloadFromHTTP(const char* s) {
|
||||
|
||||
#elif PLATFORM_ESPIDF
|
||||
#elif PLATFORM_TR6260
|
||||
#elif PLATFORM_RTL87X0C
|
||||
#elif PLATFORM_W600 || PLATFORM_W800
|
||||
t_http_fwup(s);
|
||||
#elif PLATFORM_XR809
|
||||
|
||||
@ -213,18 +213,21 @@ static void tcp_server_thread(beken_thread_arg_t arg)
|
||||
socklen_t addr_len = sizeof(source_addr);
|
||||
|
||||
int new_idx = 0;
|
||||
for(int i = 0; i < max_socks; ++i)
|
||||
{
|
||||
if(sock[i].isCompleted)
|
||||
{
|
||||
if(sock[i].thread != NULL)
|
||||
{
|
||||
rtos_delete_thread(&sock[i].thread);
|
||||
sock[i].thread = NULL;
|
||||
}
|
||||
sock[i].isCompleted = false;
|
||||
sock[i].fd = INVALID_SOCK;
|
||||
}
|
||||
}
|
||||
for(new_idx = 0; new_idx < max_socks; ++new_idx)
|
||||
{
|
||||
if(sock[new_idx].isCompleted)
|
||||
{
|
||||
if(sock[new_idx].thread != NULL)
|
||||
{
|
||||
rtos_delete_thread(&sock[new_idx].thread);
|
||||
sock[new_idx].thread = NULL;
|
||||
}
|
||||
sock[new_idx].isCompleted = false;
|
||||
sock[new_idx].fd = INVALID_SOCK;
|
||||
}
|
||||
if(sock[new_idx].fd == INVALID_SOCK)
|
||||
{
|
||||
break;
|
||||
|
||||
@ -53,6 +53,20 @@ uint32_t flash_read(uint32_t flash, uint32_t addr, void* buf, uint32_t size);
|
||||
|
||||
#elif PLATFORM_ESPIDF
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "device_lock.h"
|
||||
#include "ota_8710c.h"
|
||||
#include "sys_api.h"
|
||||
|
||||
extern flash_t flash;
|
||||
extern uint32_t sys_update_ota_get_curr_fw_idx(void);
|
||||
extern uint32_t sys_update_ota_prepare_addr(void);
|
||||
extern void sys_disable_fast_boot(void);
|
||||
extern void get_fw_info(uint32_t* targetFWaddr, uint32_t* currentFWaddr, uint32_t* fw1_sn, uint32_t* fw2_sn);
|
||||
static flash_t flash_ota;
|
||||
|
||||
#else
|
||||
|
||||
extern UINT32 flash_read(char* user_buf, UINT32 count, UINT32 address);
|
||||
@ -253,6 +267,8 @@ static int http_rest_post(http_request_t* request) {
|
||||
return http_rest_post_flash(request, -1, -1);
|
||||
#elif PLATFORM_ESPIDF
|
||||
return http_rest_post_flash(request, -1, -1);
|
||||
#elif PLATFORM_RTL87X0C
|
||||
return http_rest_post_flash(request, 0, -1);
|
||||
#else
|
||||
// TODO
|
||||
ADDLOG_DEBUG(LOG_FEATURE_API, "No OTA");
|
||||
@ -2054,6 +2070,146 @@ static int http_rest_post_flash(http_request_t* request, int startaddr, int maxa
|
||||
return -1;
|
||||
}
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
uint32_t NewFWLen = 0, NewFWAddr = 0;
|
||||
uint32_t address = 0;
|
||||
uint32_t curr_fw_idx = 0;
|
||||
uint32_t flash_checksum = 0;
|
||||
uint32_t targetFWaddr;
|
||||
uint32_t currentFWaddr;
|
||||
uint32_t fw1_sn;
|
||||
uint32_t fw2_sn;
|
||||
_file_checksum file_checksum;
|
||||
file_checksum.u = 0;
|
||||
unsigned char sig_backup[32];
|
||||
int ret = 1;
|
||||
|
||||
if(request->contentLength >= 0)
|
||||
{
|
||||
towrite = request->contentLength;
|
||||
}
|
||||
NewFWAddr = sys_update_ota_prepare_addr();
|
||||
if(NewFWAddr == -1)
|
||||
{
|
||||
ret = -1;
|
||||
goto update_ota_exit;
|
||||
}
|
||||
get_fw_info(&targetFWaddr, ¤tFWaddr, &fw1_sn, &fw2_sn);
|
||||
ADDLOG_INFO(LOG_FEATURE_OTA, "Current FW addr: 0x%08X, target FW addr: 0x%08X, fw1 sn: %u, fw2 sn: %u", currentFWaddr, targetFWaddr, fw1_sn, fw2_sn);
|
||||
curr_fw_idx = sys_update_ota_get_curr_fw_idx();
|
||||
ADDLOG_INFO(LOG_FEATURE_OTA, "Current firmware index is %d", curr_fw_idx);
|
||||
int reserase = update_ota_erase_upg_region(towrite, 0, NewFWAddr);
|
||||
NewFWLen = towrite;
|
||||
if(reserase == -1)
|
||||
{
|
||||
ADDLOG_ERROR(LOG_FEATURE_OTA, "Erase failed");
|
||||
ret = -1;
|
||||
goto update_ota_exit;
|
||||
}
|
||||
if(NewFWAddr != ~0x0)
|
||||
{
|
||||
address = NewFWAddr;
|
||||
ADDLOG_INFO(LOG_FEATURE_OTA, "Start to read data %i bytes", NewFWLen);
|
||||
}
|
||||
do
|
||||
{
|
||||
// back up signature and only write it to flash till the end of OTA
|
||||
if(startaddr < 32)
|
||||
{
|
||||
memcpy(sig_backup + startaddr, writebuf, (startaddr + writelen > 32 ? (32 - startaddr) : writelen));
|
||||
memset(writebuf, 0xFF, (startaddr + writelen > 32 ? (32 - startaddr) : writelen));
|
||||
ADDLOG_DEBUG(LOG_FEATURE_OTA, "sig_backup for% d bytes from index% d", (startaddr + writelen > 32 ? (32 - startaddr) : writelen), startaddr);
|
||||
}
|
||||
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
if(flash_burst_write(&flash_ota, address + startaddr, writelen, (uint8_t*)writebuf) < 0)
|
||||
{
|
||||
ADDLOG_ERROR(LOG_FEATURE_OTA, "Write stream failed");
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
ret = -1;
|
||||
goto update_ota_exit;
|
||||
}
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
|
||||
rtos_delay_milliseconds(10);
|
||||
ADDLOG_DEBUG(LOG_FEATURE_OTA, "Writelen %i at %i", writelen, total);
|
||||
total += writelen;
|
||||
startaddr += writelen;
|
||||
towrite -= writelen;
|
||||
|
||||
// checksum attached at file end
|
||||
if(startaddr + writelen > NewFWLen - 4)
|
||||
{
|
||||
file_checksum.c[0] = writebuf[writelen - 4];
|
||||
file_checksum.c[1] = writebuf[writelen - 3];
|
||||
file_checksum.c[2] = writebuf[writelen - 2];
|
||||
file_checksum.c[3] = writebuf[writelen - 1];
|
||||
}
|
||||
if(towrite > 0)
|
||||
{
|
||||
writebuf = request->received;
|
||||
writelen = recv(request->fd, writebuf, request->receivedLenmax, 0);
|
||||
if(writelen < 0)
|
||||
{
|
||||
ADDLOG_DEBUG(LOG_FEATURE_OTA, "recv returned %d - end of data - remaining %d", writelen, towrite);
|
||||
}
|
||||
}
|
||||
} while((towrite > 0) && (writelen >= 0));
|
||||
ADDLOG_DEBUG(LOG_FEATURE_OTA, "%d total bytes written, verifying checksum", total);
|
||||
uint8_t* buf = (uint8_t*)os_malloc(2048);
|
||||
memset(buf, 0, 2048);
|
||||
// read flash data back and calculate checksum
|
||||
for(int i = 0; i < NewFWLen; i += 2048)
|
||||
{
|
||||
int k;
|
||||
int rlen = (startaddr - 4 - i) > 2048 ? 2048 : (startaddr - 4 - i);
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_stream_read(&flash_ota, NewFWAddr + i, rlen, buf);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
for(k = 0; k < rlen; k++)
|
||||
{
|
||||
if(i + k < 32)
|
||||
{
|
||||
flash_checksum += sig_backup[i + k];
|
||||
}
|
||||
else
|
||||
{
|
||||
flash_checksum += buf[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ADDLOG_INFO(LOG_FEATURE_OTA, "flash checksum 0x%8x attached checksum 0x%8x", flash_checksum, file_checksum.u);
|
||||
|
||||
if(file_checksum.u != flash_checksum)
|
||||
{
|
||||
ADDLOG_ERROR(LOG_FEATURE_OTA, "The checksum is wrong!");
|
||||
ret = -1;
|
||||
goto update_ota_exit;
|
||||
}
|
||||
ret = update_ota_signature(sig_backup, NewFWAddr);
|
||||
if(ret == -1)
|
||||
{
|
||||
ADDLOG_ERROR(LOG_FEATURE_OTA, "Update signature fail");
|
||||
goto update_ota_exit;
|
||||
}
|
||||
update_ota_exit:
|
||||
if(ret != -1)
|
||||
{
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_write_word(&flash, targetFWaddr, 4294967295);
|
||||
flash_write_word(&flash, currentFWaddr, 0);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
|
||||
sys_disable_fast_boot();
|
||||
if(buf) free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(buf) free(buf);
|
||||
return http_rest_error(request, ret, "error");
|
||||
}
|
||||
#else
|
||||
|
||||
init_ota(startaddr);
|
||||
@ -2092,6 +2248,7 @@ static int http_rest_post_flash(http_request_t* request, int startaddr, int maxa
|
||||
http_setup(request, httpMimeTypeJson);
|
||||
hprintf255(request, "{\"size\":%d}", total);
|
||||
poststr(request, NULL);
|
||||
CFG_IncrementOTACount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2155,6 +2312,10 @@ static int http_rest_get_flash(http_request_t* request, int startaddr, int len)
|
||||
#elif PLATFORM_LN882H || PLATFORM_ESPIDF || PLATFORM_TR6260
|
||||
// TODO:LN882H flash read?
|
||||
res = 0;
|
||||
#elif PLATFORM_RTL87X0C
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_stream_read(&flash, startaddr, readlen, (uint8_t*)buffer);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
#else
|
||||
res = flash_read((char*)buffer, readlen, startaddr);
|
||||
#endif
|
||||
|
||||
@ -35,6 +35,11 @@
|
||||
#include "esp_partition.h"
|
||||
esp_partition_t* esplfs = NULL;
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
#include "flash_api.h"
|
||||
#include "device_lock.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -724,6 +729,54 @@ static int lfs_erase(const struct lfs_config* c, lfs_block_t block)
|
||||
return res;
|
||||
}
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
extern flash_t flash;
|
||||
|
||||
static int lfs_read(const struct lfs_config* c, lfs_block_t block,
|
||||
lfs_off_t off, void* buffer, lfs_size_t size)
|
||||
{
|
||||
unsigned int startAddr = LFS_Start;
|
||||
startAddr += block * LFS_BLOCK_SIZE;
|
||||
startAddr += off;
|
||||
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_stream_read(&flash, startAddr, size, (uint8_t*)buffer);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
return LFS_ERR_OK;
|
||||
}
|
||||
|
||||
// Program a region in a block. The block must have previously
|
||||
// been erased. Negative error codes are propogated to the user.
|
||||
// May return LFS_ERR_CORRUPT if the block should be considered bad.
|
||||
static int lfs_write(const struct lfs_config* c, lfs_block_t block,
|
||||
lfs_off_t off, const void* buffer, lfs_size_t size)
|
||||
{
|
||||
unsigned int startAddr = LFS_Start;
|
||||
startAddr += block * LFS_BLOCK_SIZE;
|
||||
startAddr += off;
|
||||
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_stream_write(&flash, startAddr, size, (uint8_t*)buffer);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
return LFS_ERR_OK;
|
||||
}
|
||||
|
||||
// Erase a block. A block must be erased before being programmed.
|
||||
// The state of an erased block is undefined. Negative error codes
|
||||
// are propogated to the user.
|
||||
// May return LFS_ERR_CORRUPT if the block should be considered bad.
|
||||
static int lfs_erase(const struct lfs_config* c, lfs_block_t block)
|
||||
{
|
||||
unsigned int startAddr = LFS_Start;
|
||||
startAddr += block * LFS_BLOCK_SIZE;
|
||||
|
||||
device_mutex_lock(RT_DEV_LOCK_FLASH);
|
||||
flash_erase_sector(&flash, startAddr);
|
||||
device_mutex_unlock(RT_DEV_LOCK_FLASH);
|
||||
return LFS_ERR_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Sync the state of the underlying block device. Negative error codes
|
||||
|
||||
@ -74,6 +74,12 @@
|
||||
#define LFS_BLOCKS_START_MIN PARTION_LMA_LFS
|
||||
#define LFS_BLOCKS_END PARTION_LMA_LFS + 0x20000
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
#define LFS_BLOCKS_START 0x1D0000
|
||||
#define LFS_BLOCKS_START_MIN 0x1D0000
|
||||
#define LFS_BLOCKS_END LFS_BLOCKS_START + 0x20000
|
||||
|
||||
#else
|
||||
// TODO
|
||||
// start 0x1000 after OTA addr
|
||||
|
||||
@ -1634,7 +1634,7 @@ static BENCHMARK_TEST_INFO* info = NULL;
|
||||
|
||||
#if WINDOWS
|
||||
|
||||
#elif PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800 || PLATFORM_ESPIDF || PLATFORM_TR6260
|
||||
#elif PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800 || PLATFORM_ESPIDF || PLATFORM_TR6260 || PLATFORM_RTL87X0C
|
||||
static void mqtt_timer_thread(void* param)
|
||||
{
|
||||
while (1)
|
||||
@ -1674,7 +1674,7 @@ commandResult_t MQTT_StartMQTTTestThread(const void* context, const char* cmd, c
|
||||
|
||||
#if WINDOWS
|
||||
|
||||
#elif PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800 || PLATFORM_ESPIDF || PLATFORM_TR6260
|
||||
#elif PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800 || PLATFORM_ESPIDF || PLATFORM_TR6260 || PLATFORM_RTL87X0C
|
||||
xTaskCreate(mqtt_timer_thread, "mqtt", 1024, (void*)info, 15, NULL);
|
||||
#elif PLATFORM_XR809 || PLATFORM_LN882H
|
||||
OS_TimerSetInvalid(&timer);
|
||||
@ -1914,11 +1914,12 @@ OBK_Publish_Result MQTT_DoItemPublish(int idx)
|
||||
sprintf(dataStr, "%d", LWIP_GetActiveSockets());
|
||||
return MQTT_DoItemPublishString("sockets", dataStr);
|
||||
|
||||
|
||||
#ifndef NO_CHIP_TEMPERATURE
|
||||
case PUBLISHITEM_SELF_TEMP:
|
||||
sprintf(dataStr, "%.2f", getInternalTemperature());
|
||||
return MQTT_DoItemPublishString("temp", dataStr);
|
||||
|
||||
#endif
|
||||
|
||||
case PUBLISHITEM_SELF_RSSI:
|
||||
sprintf(dataStr, "%d", HAL_GetWifiStrength());
|
||||
return MQTT_DoItemPublishString("rssi", dataStr);
|
||||
|
||||
@ -151,6 +151,8 @@ void CFG_SetDefaultConfig() {
|
||||
strcpy_safe(g_cfg.mqtt_group, "esp", sizeof(g_cfg.mqtt_group));
|
||||
#elif PLATFORM_TR6260
|
||||
strcpy_safe(g_cfg.mqtt_group, "tr6260", sizeof(g_cfg.mqtt_group));
|
||||
#elif PLATFORM_RTL87X0C
|
||||
strcpy_safe(g_cfg.mqtt_group, "rtl87x0c", sizeof(g_cfg.mqtt_group));
|
||||
#elif WINDOWS
|
||||
strcpy_safe(g_cfg.mqtt_group, "bekens", sizeof(g_cfg.mqtt_group));
|
||||
#else
|
||||
|
||||
@ -105,6 +105,11 @@ typedef long BaseType_t;
|
||||
#define DEVICENAME_PREFIX_SHORT "tr6260"
|
||||
#define PLATFORM_MCU_NAME "TR6260"
|
||||
#define MANUFACTURER "Transa Semi"
|
||||
#elif PLATFORM_RTL87X0C
|
||||
#define DEVICENAME_PREFIX_FULL "OpenRTL87X0C"
|
||||
#define DEVICENAME_PREFIX_SHORT "rtl87x0C"
|
||||
#define PLATFORM_MCU_NAME "RTL87X0C"
|
||||
#define MANUFACTURER "Realtek"
|
||||
#else
|
||||
#error "You must define a platform.."
|
||||
This platform is not supported, error!
|
||||
@ -134,6 +139,8 @@ This platform is not supported, error!
|
||||
#define USER_SW_VER PLATFORM_MCU_NAME "_Test"
|
||||
#elif defined(PLATFORM_TR6260)
|
||||
#define USER_SW_VER "TR6260_Test"
|
||||
#elif defined(PLATFORM_RTL87X0C)
|
||||
#define USER_SW_VER "RTL87X0C_Test"
|
||||
#else
|
||||
#define USER_SW_VER "unknown"
|
||||
#endif
|
||||
@ -266,6 +273,7 @@ OSStatus rtos_create_thread( beken_thread_t* thread,
|
||||
uint8_t priority, const char* name,
|
||||
beken_thread_function_t function,
|
||||
uint32_t stack_size, beken_thread_arg_t arg );
|
||||
OSStatus rtos_suspend_thread(beken_thread_t* thread);
|
||||
typedef unsigned int u32;
|
||||
|
||||
|
||||
@ -309,6 +317,7 @@ OSStatus rtos_create_thread( beken_thread_t* thread,
|
||||
uint8_t priority, const char* name,
|
||||
beken_thread_function_t function,
|
||||
uint32_t stack_size, beken_thread_arg_t arg );
|
||||
OSStatus rtos_suspend_thread(beken_thread_t* thread);
|
||||
|
||||
#include "common/framework/platform_init.h"
|
||||
|
||||
@ -356,6 +365,7 @@ OSStatus rtos_create_thread( beken_thread_t* thread,
|
||||
uint8_t priority, const char* name,
|
||||
beken_thread_function_t function,
|
||||
uint32_t stack_size, beken_thread_arg_t arg );
|
||||
OSStatus rtos_suspend_thread(beken_thread_t* thread);
|
||||
|
||||
|
||||
#elif PLATFORM_LN882H
|
||||
@ -387,6 +397,7 @@ OSStatus rtos_create_thread( beken_thread_t* thread,
|
||||
uint8_t priority, const char* name,
|
||||
beken_thread_function_t function,
|
||||
uint32_t stack_size, beken_thread_arg_t arg );
|
||||
OSStatus rtos_suspend_thread(beken_thread_t* thread);
|
||||
|
||||
#elif PLATFORM_ESPIDF
|
||||
|
||||
@ -422,6 +433,7 @@ OSStatus rtos_create_thread(beken_thread_t* thread,
|
||||
uint8_t priority, const char* name,
|
||||
beken_thread_function_t function,
|
||||
uint32_t stack_size, beken_thread_arg_t arg);
|
||||
OSStatus rtos_suspend_thread(beken_thread_t* thread);
|
||||
|
||||
#define portTICK_RATE_MS portTICK_PERIOD_MS
|
||||
#define portTickType TickType_t
|
||||
@ -482,11 +494,65 @@ OSStatus rtos_create_thread(beken_thread_t* thread,
|
||||
uint8_t priority, const char* name,
|
||||
beken_thread_function_t function,
|
||||
uint32_t stack_size, beken_thread_arg_t arg);
|
||||
OSStatus rtos_suspend_thread(beken_thread_t* thread);
|
||||
|
||||
#define GLOBAL_INT_DECLARATION() ;
|
||||
#define GLOBAL_INT_DISABLE() ;
|
||||
#define GLOBAL_INT_RESTORE() ;
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#include "queue.h"
|
||||
#include "event_groups.h"
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
typedef unsigned int UINT32;
|
||||
|
||||
#undef ASSERT
|
||||
#define ASSERT
|
||||
|
||||
#define os_malloc pvPortMalloc
|
||||
#define os_free vPortFree
|
||||
#define os_memset memset
|
||||
#define os_strcpy strcpy
|
||||
|
||||
#define bk_printf printf
|
||||
|
||||
// OS_MSleep?
|
||||
#define rtos_delay_milliseconds(x) vTaskDelay(x / portTICK_PERIOD_MS)
|
||||
#define delay_ms(x) vTaskDelay(x / portTICK_PERIOD_MS)
|
||||
|
||||
#define kNoErr 0 //! No error occurred.
|
||||
typedef void* beken_thread_arg_t;
|
||||
typedef void* beken_thread_t;
|
||||
typedef void (*beken_thread_function_t)(beken_thread_arg_t arg);
|
||||
typedef int OSStatus;
|
||||
|
||||
#define BEKEN_DEFAULT_WORKER_PRIORITY (6)
|
||||
#define BEKEN_APPLICATION_PRIORITY (7)
|
||||
|
||||
OSStatus rtos_delete_thread(beken_thread_t* thread);
|
||||
OSStatus rtos_create_thread(beken_thread_t* thread,
|
||||
uint8_t priority, const char* name,
|
||||
beken_thread_function_t function,
|
||||
uint32_t stack_size, beken_thread_arg_t arg);
|
||||
OSStatus rtos_suspend_thread(beken_thread_t* thread);
|
||||
|
||||
#define GLOBAL_INT_DECLARATION() ;
|
||||
#define GLOBAL_INT_DISABLE() ;
|
||||
#define GLOBAL_INT_RESTORE() ;
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#include "gw_intf.h"
|
||||
|
||||
@ -1018,6 +1018,8 @@ typedef enum channelType_e {
|
||||
#endif
|
||||
#elif PLATFORM_TR6260
|
||||
#define PLATFORM_GPIO_MAX 25
|
||||
#elif PLATFORM_RTL87X0C
|
||||
#define PLATFORM_GPIO_MAX 24
|
||||
#else
|
||||
#define PLATFORM_GPIO_MAX 29
|
||||
#endif
|
||||
|
||||
@ -17,7 +17,8 @@
|
||||
|
||||
#if PLATFORM_XR809
|
||||
|
||||
#define OBK_DISABLE_ALL_DRIVERS 1
|
||||
#define NO_CHIP_TEMPERATURE 1
|
||||
#define OBK_DISABLE_ALL_DRIVERS 1
|
||||
|
||||
#elif PLATFORM_W600
|
||||
|
||||
@ -218,6 +219,7 @@
|
||||
|
||||
#elif PLATFORM_TR6260
|
||||
|
||||
#define NO_CHIP_TEMPERATURE 1
|
||||
#define ENABLE_LITTLEFS 1
|
||||
#define NEW_TCP_SERVER 1
|
||||
#define ENABLE_EXPAND_CONSTANT 1
|
||||
@ -228,13 +230,34 @@
|
||||
#define ENABLE_DRIVER_LED 1
|
||||
#define ENABLE_DRIVER_WEMO 1
|
||||
|
||||
#elif PLATFORM_RTL87X0C
|
||||
|
||||
#define NO_CHIP_TEMPERATURE 1
|
||||
#define ENABLE_LITTLEFS 1
|
||||
#define NEW_TCP_SERVER 1
|
||||
#define ENABLE_DRIVER_TUYAMCU 1
|
||||
#define ENABLE_TASMOTADEVICEGROUPS 1
|
||||
#define ENABLE_NTP 1
|
||||
#define ENABLE_CALENDAR_EVENTS 1
|
||||
#define ENABLE_EXPAND_CONSTANT 1
|
||||
#define ENABLE_TASMOTA_JSON 1
|
||||
#define ENABLE_I2C 1
|
||||
#define ENABLE_DRIVER_AHT2X 1
|
||||
#define ENABLE_DRIVER_BMPI2C 1
|
||||
#define ENABLE_DRIVER_DS1820 1
|
||||
#define ENABLE_DRIVER_LED 1
|
||||
#define ENABLE_DRIVER_WEMO 1
|
||||
#define ENABLE_DRIVER_CHT83XX 1
|
||||
#define ENABLE_DRIVER_DHT 1
|
||||
#define ENABLE_DRIVER_BL0942 1
|
||||
#define ENABLE_DRIVER_BL0937 1
|
||||
#define ENABLE_DRIVER_CSE7766 1
|
||||
|
||||
#else
|
||||
|
||||
#error "Platform not defined"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// closing OBK_CONFIG_H
|
||||
#endif
|
||||
|
||||
@ -212,7 +212,7 @@ int LWIP_GetActiveSockets() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_BL602) || defined(PLATFORM_W800) || defined(PLATFORM_W600) || defined(PLATFORM_LN882H) || defined(PLATFORM_ESPIDF) || defined(PLATFORM_TR6260)
|
||||
#if defined(PLATFORM_BL602) || defined(PLATFORM_W800) || defined(PLATFORM_W600) || defined(PLATFORM_LN882H) || defined(PLATFORM_ESPIDF) || defined(PLATFORM_TR6260) || defined(PLATFORM_RTL87X0C)
|
||||
|
||||
OSStatus rtos_create_thread(beken_thread_t* thread,
|
||||
uint8_t priority, const char* name,
|
||||
@ -616,7 +616,8 @@ void Main_OnEverySecond()
|
||||
LED_RunOnEverySecond();
|
||||
#ifndef OBK_DISABLE_ALL_DRIVERS
|
||||
DRV_OnEverySecond();
|
||||
#if defined(PLATFORM_BEKEN) || defined(WINDOWS) || defined(PLATFORM_BL602) || defined(PLATFORM_ESPIDF)
|
||||
#if defined(PLATFORM_BEKEN) || defined(WINDOWS) || defined(PLATFORM_BL602) || defined(PLATFORM_ESPIDF) \
|
||||
|| defined (PLATFORM_RTL87X0C)
|
||||
UART_RunEverySecond();
|
||||
#endif
|
||||
#endif
|
||||
@ -877,15 +878,7 @@ void Main_OnEverySecond()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef PLATFORM_BEKEN
|
||||
bk_wdg_reload();
|
||||
#elif PLATFORM_BL602
|
||||
bl_wdt_feed();
|
||||
#elif PLATFORM_W600 || PLATFORM_W800
|
||||
tls_watchdog_clr();
|
||||
#elif PLATFORM_LN882H
|
||||
hal_wdt_cnt_restart(WDT_BASE);
|
||||
#endif
|
||||
HAL_Run_WDT();
|
||||
// force it to sleep... we MUST have some idle task processing
|
||||
// else task memory doesn't get freed
|
||||
rtos_delay_milliseconds(1);
|
||||
@ -940,7 +933,9 @@ void QuickTick(void* param)
|
||||
g_last_time = g_time;
|
||||
|
||||
|
||||
#if (defined WINDOWS) || (defined PLATFORM_BEKEN) || (defined PLATFORM_BL602) || (defined PLATFORM_LN882H) || (defined PLATFORM_ESPIDF) || (defined PLATFORM_TR6260)
|
||||
#if (defined WINDOWS) || (defined PLATFORM_BEKEN) || (defined PLATFORM_BL602) \
|
||||
|| (defined PLATFORM_LN882H) || (defined PLATFORM_ESPIDF) || (defined PLATFORM_TR6260) \
|
||||
|| (defined PLATFORM_RTL87X0C)
|
||||
SVM_RunThreads(g_deltaTimeMS);
|
||||
#endif
|
||||
RepeatingEvents_RunUpdate(g_deltaTimeMS * 0.001f);
|
||||
@ -991,11 +986,11 @@ void QuickTick(void* param)
|
||||
// this is the bit which runs the quick tick timer
|
||||
#if WINDOWS
|
||||
|
||||
#elif PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800 || PLATFORM_TR6260
|
||||
#elif PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800 || PLATFORM_TR6260 || defined(PLATFORM_RTL87X0C)
|
||||
void quick_timer_thread(void* param)
|
||||
{
|
||||
while (1) {
|
||||
vTaskDelay(QUICK_TMR_DURATION);
|
||||
vTaskDelay(QUICK_TMR_DURATION / portTICK_PERIOD_MS);
|
||||
QuickTick(0);
|
||||
}
|
||||
}
|
||||
@ -1010,7 +1005,7 @@ void QuickTick_StartThread(void)
|
||||
{
|
||||
#if WINDOWS
|
||||
|
||||
#elif PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800 || PLATFORM_TR6260
|
||||
#elif PLATFORM_BL602 || PLATFORM_W600 || PLATFORM_W800 || PLATFORM_TR6260 || defined(PLATFORM_RTL87X0C)
|
||||
|
||||
xTaskCreate(quick_timer_thread, "quick", 1024, NULL, 15, NULL);
|
||||
#elif PLATFORM_ESPIDF
|
||||
@ -1099,30 +1094,7 @@ void Main_Init_AfterDelay_Unsafe(bool bStartAutoRunScripts) {
|
||||
CMD_ExecuteCommand(CFG_GetShortStartupCommand(), COMMAND_FLAG_SOURCE_SCRIPT);
|
||||
CMD_ExecuteCommand("startScript autoexec.bat", COMMAND_FLAG_SOURCE_SCRIPT);
|
||||
}
|
||||
#ifdef PLATFORM_BEKEN
|
||||
bk_wdg_initialize(10000);
|
||||
#elif PLATFORM_BL602
|
||||
// max is 4 seconds or so...
|
||||
// #define MAX_MS_WDT (65535/16)
|
||||
bl_wdt_init(3000);
|
||||
#elif PLATFORM_W600 || PLATFORM_W800
|
||||
tls_watchdog_init(5*1000*1000);
|
||||
#elif PLATFORM_LN882H
|
||||
/* Watchdog initialization */
|
||||
wdt_init_t_def wdt_init;
|
||||
memset(&wdt_init,0,sizeof(wdt_init));
|
||||
wdt_init.wdt_rmod = WDT_RMOD_1; // When equal to 0, the counter is reset directly when it overflows; when equal to 1, an interrupt is generated first when the counter overflows, and if it overflows again, it resets.
|
||||
wdt_init.wdt_rpl = WDT_RPL_32_PCLK; // Set the reset delay time
|
||||
wdt_init.top = WDT_TOP_VALUE_9; //wdt cnt value = 0x1FFFF Time = 4.095 s
|
||||
hal_wdt_init(WDT_BASE, &wdt_init);
|
||||
|
||||
/* Configure watchdog interrupt */
|
||||
NVIC_SetPriority(WDT_IRQn, 4);
|
||||
NVIC_EnableIRQ(WDT_IRQn);
|
||||
|
||||
/* Enable watchdog */
|
||||
hal_wdt_en(WDT_BASE,HAL_ENABLE);
|
||||
#endif
|
||||
HAL_Configure_WDT();
|
||||
}
|
||||
void Main_Init_BeforeDelay_Unsafe(bool bAutoRunScripts) {
|
||||
g_unsafeInitDone = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user