add web test, delete Keil, new test ver 0.6

This commit is contained in:
pvvx 2024-01-17 02:48:41 +03:00
parent 1a15f7b3a0
commit c97cbcabed
25 changed files with 6351 additions and 6761 deletions

File diff suppressed because it is too large Load diff

2922
BTH01_v06.hex Normal file

File diff suppressed because it is too large Load diff

View file

@ -3,11 +3,11 @@ Custom firmware for Tuya [THB2](https://pvvx.github.io/THB2) and [BTH01](https:/
* Проект в начальной стадии разработки, до появления функционального OTA.
В плане проекта предусматривается дальнейшая поддержка [BTH01 с датчиком AHT30](https://github.com/pvvx/THB2/issues/1#issuecomment-1892557983), [TH-05](https://pvvx.github.io/TH-05).
В плане проекта предусматривается дальнейшая поддержка [TH-05](https://pvvx.github.io/TH-05).
Прошивка V0.5 для THB2 (файл THB2_v05.hex).
Прошивка для THB2 (файл THB2_v06.hex).
Прошивка V0.5 для BTH01 с датчиком CHT8305 (файл BTH01_v05.hex).
Прошивка для BTH01 (файл BTH01_v06.hex).
## Основные характеристики:
@ -58,7 +58,7 @@ python3 rdwr_phy62x2.py -p COM11 -b 1000000 -r we 0 ff_thb2.bin
## Сборка прошивки.
Для сборки прошивки используется GNU Arm Embedded Toolchain или Keil.
Для сборки прошивки используется GNU Arm Embedded Toolchain.
Для работы в Eclipce используете импорт проекта и установите toolchain.path.

File diff suppressed because it is too large Load diff

2906
THB2_v06.hex Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,168 +0,0 @@
;/**************************************************************************//**
; * @file startup_ARMCM0.s
; * @brief CMSIS Core Device Startup File for
; * ARMCM0 Device
; * @version V1.0.1
; * @date 23. July 2019
; ******************************************************************************/
;/*
; * Copyright (c) 2009-2019 Arm Limited. All rights reserved.
; *
; * SPDX-License-Identifier: Apache-2.0
; *
; * Licensed under the Apache License, Version 2.0 (the License); you may
; * not use this file except in compliance with the License.
; * You may obtain a copy of the License at
; *
; * www.apache.org/licenses/LICENSE-2.0
; *
; * Unless required by applicable law or agreed to in writing, software
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; * See the License for the specific language governing permissions and
; * limitations under the License.
; */
;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
;<h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
;</h>
Stack_Size EQU 0x00000400
AREA STACK, NOINIT, READWRITE, ALIGN=3
__stack_limit
Stack_Mem SPACE Stack_Size
__initial_sp
;<h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
;</h>
Heap_Size EQU 0x00000C00
IF Heap_Size != 0 ; Heap is provided
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
ENDIF
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; -14 NMI Handler
DCD HardFault_Handler ; -13 Hard Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; -5 SVCall Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD PendSV_Handler ; -2 PendSV Handler
DCD SysTick_Handler ; -1 SysTick Handler
; Interrupts
DCD Interrupt0_Handler ; 0 Interrupt 0
DCD Interrupt1_Handler ; 1 Interrupt 1
DCD Interrupt2_Handler ; 2 Interrupt 2
DCD Interrupt3_Handler ; 3 Interrupt 3
DCD Interrupt4_Handler ; 4 Interrupt 4
DCD Interrupt5_Handler ; 5 Interrupt 5
DCD Interrupt6_Handler ; 6 Interrupt 6
DCD Interrupt7_Handler ; 7 Interrupt 7
DCD Interrupt8_Handler ; 8 Interrupt 8
DCD Interrupt9_Handler ; 9 Interrupt 9
SPACE ( 22 * 4) ; Interrupts 10 .. 31 are left out
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset Handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; The default macro is not used for HardFault_Handler
; because this results in a poor debug illusion.
HardFault_Handler PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
; Macro to define default exception/interrupt handlers.
; Default handler are weak symbols with an endless loop.
; They can be overwritten by real handlers.
MACRO
Set_Default_Handler $Handler_Name
$Handler_Name PROC
EXPORT $Handler_Name [WEAK]
B .
ENDP
MEND
; Default exception/interrupt handler
Set_Default_Handler NMI_Handler
Set_Default_Handler SVC_Handler
Set_Default_Handler PendSV_Handler
Set_Default_Handler SysTick_Handler
Set_Default_Handler Interrupt0_Handler
Set_Default_Handler Interrupt1_Handler
Set_Default_Handler Interrupt2_Handler
Set_Default_Handler Interrupt3_Handler
Set_Default_Handler Interrupt4_Handler
Set_Default_Handler Interrupt5_Handler
Set_Default_Handler Interrupt6_Handler
Set_Default_Handler Interrupt7_Handler
Set_Default_Handler Interrupt8_Handler
Set_Default_Handler Interrupt9_Handler
ALIGN
; User setup Stack & Heap
IF :LNOT::DEF:__MICROLIB
IMPORT __use_two_region_memory
ENDIF
EXPORT __stack_limit
EXPORT __initial_sp
IF Heap_Size != 0 ; Heap is provided
EXPORT __heap_base
EXPORT __heap_limit
ENDIF
END

View file

@ -1,56 +0,0 @@
/**************************************************************************//**
* @file system_ARMCM0.c
* @brief CMSIS Device System Source File for
* ARMCM0 Device
* @version V1.0.0
* @date 09. July 2018
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ARMCM0.h"
/*----------------------------------------------------------------------------
Define clocks
*----------------------------------------------------------------------------*/
#define XTAL (50000000UL) /* Oscillator frequency */
#define SYSTEM_CLOCK (XTAL / 2U)
/*----------------------------------------------------------------------------
System Core Clock Variable
*----------------------------------------------------------------------------*/
uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */
/*----------------------------------------------------------------------------
System Core Clock update function
*----------------------------------------------------------------------------*/
void SystemCoreClockUpdate (void)
{
SystemCoreClock = SYSTEM_CLOCK;
}
/*----------------------------------------------------------------------------
System initialization function
*----------------------------------------------------------------------------*/
void SystemInit (void)
{
SystemCoreClock = SYSTEM_CLOCK;
}

View file

@ -1,21 +0,0 @@
/*
* Auto generated Run-Time-Environment Configuration File
* *** Do not modify ! ***
*
* Project: 'TestTHB2'
* Target: 'Target 1'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "ARMCM0.h"
#endif /* RTE_COMPONENTS_H */

View file

@ -1,743 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
<SchemaVersion>2.1</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Targets>
<Target>
<TargetName>Target 1</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>ARMCM0</Device>
<Vendor>ARM</Vendor>
<PackID>ARM.CMSIS.5.8.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x20000) IROM(0x00000000,0x40000) CPUTYPE("Cortex-M0") CLOCK(12000000) ESEL ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
<FlashDriverDll>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NEW_DEVICE -FS00 -FL040000 -FP0($$Device:ARMCM0$Device\ARM\Flash\NEW_DEVICE.FLM))</FlashDriverDll>
<DeviceId>0</DeviceId>
<RegisterFile>$$Device:ARMCM0$Device\ARM\ARMCM0\Include\ARMCM0.h</RegisterFile>
<MemoryEnv></MemoryEnv>
<Cmp></Cmp>
<Asm></Asm>
<Linker></Linker>
<OHString></OHString>
<InfinionOptionDll></InfinionOptionDll>
<SLE66CMisc></SLE66CMisc>
<SLE66AMisc></SLE66AMisc>
<SLE66LinkerMisc></SLE66LinkerMisc>
<SFDFile>$$Device:ARMCM0$Device\ARM\SVD\ARMCM0.svd</SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
<BinPath></BinPath>
<IncludePath></IncludePath>
<LibPath></LibPath>
<RegisterFilePath></RegisterFilePath>
<DBRegisterFilePath></DBRegisterFilePath>
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
<ButtonStop>0</ButtonStop>
<NotGenerated>0</NotGenerated>
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\Objects\</OutputDirectory>
<OutputName>TestTHB2</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>1</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
<ListingPath>.\Listings\</ListingPath>
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
<nStopU2X>0</nStopU2X>
</BeforeCompile>
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
<UserProg1Name></UserProg1Name>
<UserProg2Name></UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopB1X>0</nStopB1X>
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
<RunUserProg1>1</RunUserProg1>
<RunUserProg2>1</RunUserProg2>
<UserProg1Name>fromelf.exe .\Objects\TestTHB2.axf --i32combined --output .\bin\TestTHB2.hex</UserProg1Name>
<UserProg2Name>fromelf -c -a -d -e -v -o TestTHB2.asm ./Objects/TestTHB2.axf</UserProg2Name>
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>0</SelectedForBatchBuild>
<SVCSIdString></SVCSIdString>
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>0</AlwaysBuild>
<GenerateAssemblyFile>0</GenerateAssemblyFile>
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<DllOption>
<SimDllName>SARMCM3.DLL</SimDllName>
<SimDllArguments> </SimDllArguments>
<SimDlgDll>DARMCM1.DLL</SimDlgDll>
<SimDlgDllArguments>-pCM0</SimDlgDllArguments>
<TargetDllName>SARMCM3.DLL</TargetDllName>
<TargetDllArguments> </TargetDllArguments>
<TargetDlgDll>TARMCM1.DLL</TargetDlgDll>
<TargetDlgDllArguments>-pCM0</TargetDlgDllArguments>
</DllOption>
<DebugOption>
<OPTHX>
<HexSelection>1</HexSelection>
<HexRangeLowAddress>0</HexRangeLowAddress>
<HexRangeHighAddress>0</HexRangeHighAddress>
<HexOffset>0</HexOffset>
<Oh166RecLen>16</Oh166RecLen>
</OPTHX>
</DebugOption>
<Utilities>
<Flash1>
<UseTargetDll>1</UseTargetDll>
<UseExternalTool>1</UseExternalTool>
<RunIndependent>0</RunIndependent>
<UpdateFlashBeforeDebugging>1</UpdateFlashBeforeDebugging>
<Capability>1</Capability>
<DriverSelection>4096</DriverSelection>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2CM3.DLL</Flash2>
<Flash3>"" ()</Flash3>
<Flash4>.\ram.ini</Flash4>
<pFcarmOut></pFcarmOut>
<pFcarmGrp></pFcarmGrp>
<pFcArmRoot></pFcArmRoot>
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
<ArmAdsMisc>
<GenerateListings>0</GenerateListings>
<asHll>1</asHll>
<asAsm>1</asAsm>
<asMacX>1</asMacX>
<asSyms>1</asSyms>
<asFals>1</asFals>
<asDbgD>1</asDbgD>
<asForm>1</asForm>
<ldLst>0</ldLst>
<ldmm>1</ldmm>
<ldXref>1</ldXref>
<BigEnd>0</BigEnd>
<AdsALst>1</AdsALst>
<AdsACrf>1</AdsACrf>
<AdsANop>0</AdsANop>
<AdsANot>0</AdsANot>
<AdsLLst>1</AdsLLst>
<AdsLmap>1</AdsLmap>
<AdsLcgr>1</AdsLcgr>
<AdsLsym>1</AdsLsym>
<AdsLszi>1</AdsLszi>
<AdsLtoi>1</AdsLtoi>
<AdsLsun>1</AdsLsun>
<AdsLven>1</AdsLven>
<AdsLsxf>1</AdsLsxf>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M0"</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
<hadIROM>1</hadIROM>
<hadIRAM>1</hadIRAM>
<hadXRAM>0</hadXRAM>
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<RvdsMve>0</RvdsMve>
<RvdsCdeCp>0</RvdsCdeCp>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
<useUlib>1</useUlib>
<EndSel>1</EndSel>
<uLtcg>0</uLtcg>
<nSecure>0</nSecure>
<RoSelD>3</RoSelD>
<RwSelD>3</RwSelD>
<CodeSel>0</CodeSel>
<OptFeed>0</OptFeed>
<NoZi1>0</NoZi1>
<NoZi2>0</NoZi2>
<NoZi3>0</NoZi3>
<NoZi4>0</NoZi4>
<NoZi5>0</NoZi5>
<Ro1Chk>0</Ro1Chk>
<Ro2Chk>0</Ro2Chk>
<Ro3Chk>0</Ro3Chk>
<Ir1Chk>0</Ir1Chk>
<Ir2Chk>0</Ir2Chk>
<Ra1Chk>0</Ra1Chk>
<Ra2Chk>0</Ra2Chk>
<Ra3Chk>0</Ra3Chk>
<Im1Chk>0</Im1Chk>
<Im2Chk>0</Im2Chk>
<OnChipMemories>
<Ocm1>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm1>
<Ocm2>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm2>
<Ocm3>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm3>
<Ocm4>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm4>
<Ocm5>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm5>
<Ocm6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</Ocm6>
<IRAM>
<Type>0</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x20000</Size>
</IRAM>
<IROM>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x40000</Size>
</IROM>
<XRAM>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</XRAM>
<OCR_RVCT1>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT1>
<OCR_RVCT2>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT2>
<OCR_RVCT3>
<Type>1</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x20000000</StartAddress>
<Size>0x400</Size>
</OCR_RVCT4>
<OCR_RVCT5>
<Type>1</Type>
<StartAddress>0x1fff8000</StartAddress>
<Size>0x1f40</Size>
</OCR_RVCT5>
<OCR_RVCT6>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT6>
<OCR_RVCT7>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT7>
<OCR_RVCT8>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT8>
<OCR_RVCT9>
<Type>0</Type>
<StartAddress>0x1fff6000</StartAddress>
<Size>0x2000</Size>
</OCR_RVCT9>
<OCR_RVCT10>
<Type>0</Type>
<StartAddress>0x0</StartAddress>
<Size>0x0</Size>
</OCR_RVCT10>
</OnChipMemories>
<RvctStartVector></RvctStartVector>
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>4</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
<Strict>0</Strict>
<EnumInt>0</EnumInt>
<PlainCh>0</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>2</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uGnu>0</uGnu>
<useXO>0</useXO>
<v6Lang>1</v6Lang>
<v6LangP>1</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls>-DADV_NCONN_CFG=0x01 -DADV_CONN_CFG=0x02 -DSCAN_CFG=0x04 -DINIT_CFG=0x08 -DBROADCASTER_CFG=0x01 -DOBSERVER_CFG=0x02 -DPERIPHERAL_CFG=0x04 -DCENTRAL_CFG=0x08</MiscControls>
<Define>DEBUG_INFO=0 CFG_CP OSAL_CBTIMER_NUM_TASKS=1 MTU_SIZE=247 HOST_CONFIG=4 HCI_TL_NONE=1 ENABLE_LOG_ROM_=0 _BUILD_FOR_DTM_=0 DBG_ROM_MAIN=0 APP_CFG=0 OSALMEM_METRICS=0 PHY_MCU_TYPE=MCU_BUMBEE_M0 CFG_SLEEP_MODE=PWR_MODE_SLEEP DEF_GAPBOND_MGR_ENABLE=0 USE_FS=0 MAX_NUM_LL_CONN=1</Define>
<Undefine></Undefine>
<IncludePath>.\SDK\components\inc;.\SDK\components\ble\controller;.\SDK\components\osal\include;.\SDK\components\common;.\SDK\components\ble\include;.\SDK\components\ble\hci;.\SDK\components\ble\host;.\SDK\components\Profiles\ota_app;.\SDK\components\Profiles\DevInfo;.\SDK\components\Profiles\SimpleProfile;.\SDK\components\Profiles\Roles;.\source;.\SDK\components\libraries\crc16;.\SDK\components\driver\watchdog;.\SDK\components\driver\clock;.\SDK\components\arch\cm0;.\SDK\components\driver\pwrmgr;.\SDK\components\driver\uart;.\SDK\components\driver\gpio;.\SDK\components\driver\timer;.\SDK\misc;.\SDK\components\driver\log;.\SDK\components\libraries\cliface;.\SDK\components\driver\key;.\SDK\components\driver\pwm;.\SDK\components\driver\flash;.\SDK\components\libraries\fs;.\SDK\components\driver\led_light;.\SDK\components\driver\i2c;.\SDK\components\Profiles\Batt;.\SDK\components\driver\adc</IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>1</interw>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<thumb>0</thumb>
<SplitLS>0</SplitLS>
<SwStkChk>0</SwStkChk>
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<ClangAsOpt>4</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
<LDads>
<umfTarg>0</umfTarg>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<noStLib>0</noStLib>
<RepFail>0</RepFail>
<useFile>0</useFile>
<TextAddressRange>0</TextAddressRange>
<DataAddressRange>0</DataAddressRange>
<pXoBase></pXoBase>
<ScatterFile>.\scatter_load.sct</ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc>.\SDK\misc\bb_rom_sym_m0.txt --keep=jump_table_base --keep=global_config</Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
</TargetArmAds>
</TargetOption>
<Groups>
<Group>
<GroupName>driver</GroupName>
<Files>
<File>
<FileName>uart.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\driver\uart\uart.c</FilePath>
</File>
<File>
<FileName>clock.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\driver\clock\clock.c</FilePath>
</File>
<File>
<FileName>gpio.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\driver\gpio\gpio.c</FilePath>
</File>
<File>
<FileName>watchdog.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\driver\watchdog\watchdog.c</FilePath>
</File>
<File>
<FileName>pwrmgr.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\driver\pwrmgr\pwrmgr.c</FilePath>
</File>
<File>
<FileName>my_printf.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\driver\log\my_printf.c</FilePath>
</File>
<File>
<FileName>osal_snv.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\osal\snv\osal_snv.c</FilePath>
</File>
<File>
<FileName>flash.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\driver\flash\flash.c</FilePath>
</File>
<File>
<FileName>fs.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\libraries\fs\fs.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>profile</GroupName>
<Files>
<File>
<FileName>gap.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\profiles\Roles\gap.c</FilePath>
</File>
<File>
<FileName>gapbondmgr.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\profiles\Roles\gapbondmgr.c</FilePath>
<FileOption>
<CommonProperty>
<UseCPPCompiler>2</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
</File>
<File>
<FileName>gapgattserver.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\profiles\Roles\gapgattserver.c</FilePath>
</File>
<File>
<FileName>gattservapp.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\components\profiles\GATT\gattservapp.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>jump</GroupName>
<Files>
<File>
<FileName>jump_table.c</FileName>
<FileType>1</FileType>
<FilePath>.\SDK\misc\jump_table.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>lib</GroupName>
<Files>
<File>
<FileName>rf.lib</FileName>
<FileType>4</FileType>
<FilePath>.\SDK\lib\rf.lib</FilePath>
</File>
<File>
<FileName>ble_host.lib</FileName>
<FileType>4</FileType>
<FilePath>.\SDK\lib\ble_host.lib</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>TestTHB2</GroupName>
<Files>
<File>
<FileName>peripheral_main.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\peripheral_main.c</FilePath>
</File>
<File>
<FileName>thb2_main.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\thb2_main.c</FilePath>
</File>
<File>
<FileName>bthome_beacon.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\bthome_beacon.c</FilePath>
</File>
<File>
<FileName>sensors.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\sensors.c</FilePath>
</File>
<File>
<FileName>battery.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\battery.c</FilePath>
</File>
<File>
<FileName>thservice.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\thservice.c</FilePath>
</File>
<File>
<FileName>main.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\main.c</FilePath>
</File>
<File>
<FileName>osal_peripheral.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\osal_peripheral.c</FilePath>
</File>
<File>
<FileName>thb2_peripheral.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\thb2_peripheral.c</FilePath>
</File>
<File>
<FileName>devinfoservice.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\devinfoservice.c</FilePath>
</File>
<File>
<FileName>battservice.c</FileName>
<FileType>1</FileType>
<FilePath>.\source\battservice.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>
<Group>
<GroupName>::Device</GroupName>
<GroupOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<GroupArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>2</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
<Aads>
<interw>2</interw>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<thumb>2</thumb>
<SplitLS>2</SplitLS>
<SwStkChk>2</SwStkChk>
<NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc>
<useXO>2</useXO>
<ClangAsOpt>0</ClangAsOpt>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Aads>
</GroupArmAds>
</GroupOption>
</Group>
</Groups>
</Target>
</Targets>
<RTE>
<apis/>
<components>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="4.3.0" condition="Cortex-M Device">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.0.1" condition="ARMCM0 CMSIS">
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</component>
</components>
<files>
<file attr="config" category="sourceAsm" condition="ARMCC" name="Device\ARM\ARMCM0\Source\ARM\startup_ARMCM0.s" version="1.0.1">
<instance index="0">RTE\Device\ARMCM0\startup_ARMCM0.s</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.2.2" condition="ARMCM0 CMSIS"/>
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</file>
<file attr="config" category="sourceC" name="Device\ARM\ARMCM0\Source\system_ARMCM0.c" version="1.0.0">
<instance index="0">RTE\Device\ARMCM0\system_ARMCM0.c</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.2.2" condition="ARMCM0 CMSIS"/>
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
<targetInfos>
<targetInfo name="Target 1"/>
</targetInfos>
</file>
<file attr="config" category="sourceAsm" condition="ARMCC" name="Device\ARM\ARMCM4\Source\ARM\startup_ARMCM4.s" version="1.0.0">
<instance index="0" removed="1">RTE\Device\ARMCM4\startup_ARMCM4.s</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.0.1" condition="ARMCM4 CMSIS"/>
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
<targetInfos/>
</file>
<file attr="config" category="sourceC" name="Device\ARM\ARMCM4\Source\system_ARMCM4.c" version="1.0.0">
<instance index="0" removed="1">RTE\Device\ARMCM4\system_ARMCM4.c</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.0.1" condition="ARMCM4 CMSIS"/>
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
<targetInfos/>
</file>
<file attr="config" category="sourceAsm" condition="ARMCC" name="Device\ARM\ARMCM4\Source\ARM\startup_ARMCM4.s" version="1.0.0">
<instance index="0" removed="1">RTE\Device\ARMCM4_FP\startup_ARMCM4.s</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.0.1" condition="ARMCM4 CMSIS"/>
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
<targetInfos/>
</file>
<file attr="config" category="sourceC" name="Device\ARM\ARMCM4\Source\system_ARMCM4.c" version="1.0.0">
<instance index="0" removed="1">RTE\Device\ARMCM4_FP\system_ARMCM4.c</instance>
<component Cclass="Device" Cgroup="Startup" Cvendor="ARM" Cversion="1.0.1" condition="ARMCM4 CMSIS"/>
<package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="4.5.0"/>
<targetInfos/>
</file>
</files>
</RTE>
<LayerInfo>
<Layers>
<Layer>
<LayName>&lt;Project Info&gt;</LayName>
<LayTarg>0</LayTarg>
<LayPrjMark>1</LayPrjMark>
</Layer>
</Layers>
</LayerInfo>
</Project>

View file

@ -1 +1 @@
python3 C:\Python310\Scripts\hexinfo.py .\build\bthome_phy6222.hex
python3 C:\Python310\Scripts\hexinfo.py .\bin\THB2_v06.hex

View file

@ -1 +0,0 @@
python3 C:\Python310\Scripts\hexinfo.py .\bin\TestTHB2.hex

View file

@ -1,5 +1,5 @@
@set PATH=D:\MCU\GNU_Tools_ARM_Embedded\13.2.rel1\bin;%PATH%
@set SWVER=_v05
@set SWVER=_v06
@del /Q "THB2%SWVER%.hex"
@mkdir .\bin
@make -s clean

View file

@ -1,67 +0,0 @@
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x1fff1838 0x0E7C8 { ; load region size_region
ER_IROM1 0x1fff1838 0x0E7C8 { ; load address = execution address
;LR_IROM1 0x1fff1838 0x067C8 { ; load region size_region
; ER_IROM1 0x1fff1838 0x067C8 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (_section_standby_code_)
.ANY (_section_sram_code_)
;*.o(_section_standby_code_)
;*.o(_section_sram_code_)
.ANY (+RO)
.ANY (+RW +ZI)
}
; ER_IROM2 0x1fffc000 0x04000 { ; load address = execution address
;; rf_phy_driver.o(i.rf_phy_dtm*)
;; rf_phy_driver.o(i.rf_phy_direct_*)
; }
}
LR_ROM_JT_GC 0x1fff0000 0x00800 {
JUMP_TABLE 0x1fff0000 0x00400 {
.ANY (jump_table_mem_area)
}
GOLBAL_CONFIG 0x1fff0400 0x00400 {
.ANY (global_config_area)
}
}
LR_ROM_XIP 0x11020000 0x020000 {
ER_ROM_XIP 0x11020000 0x020000 { ; load address = execution address
gatt*.o(+RO)
gattservapp.o(+RO)
l2cap*.o(+RO)
att*.o(+RO)
linkdb.o(+RO)
sm*.o(+RO)
gap*.o(+RO)
thb2_peripheral.o(+RO)
;battservice.o(+RO)
devinfoservice.o(+RO)
thb2_main.o(+RO)
peripheral_main.o(+RO)
osal_peripheral.o(+RO)
gapgattserver.o(+RO)
;gapbondmgr.o(+RO)
uart.o(+RO)
sensors.o(+RO)
battery.o(+RO)
battservice.o(+RO)
; i2c.o(+RO)
bthome_beacon.o(+RO)
thservice.o(+RO)
main.o(+RO)
; ota_app_service.o(+RO)
; my_printf.o(+RO)
gpio.o(+RO)
;osal_snv.o(+RO)
*.o(_section_xip_code_, .conststring)
}
}

View file

@ -24,7 +24,7 @@
#include "cmd_parcer.h"
/*********************************************************************/
#define SEND_DATA_SIZE 18
#define SEND_DATA_SIZE 16
int cmd_parser(uint8_t * obuf, uint8_t * ibuf, uint32_t len) {
int olen = 0;
@ -64,13 +64,13 @@ int cmd_parser(uint8_t * obuf, uint8_t * ibuf, uint32_t len) {
osal_memcpy(&thsensor_cfg.coef, &ibuf[1], len);
flash_write_cfg(&thsensor_cfg.coef, EEP_ID_CFS, sizeof(thsensor_cfg.coef));
}
osal_memcpy(&obuf[1], &thsensor_cfg.coef, sizeof(thsensor_cfg.coef));
olen = sizeof(thsensor_cfg.coef) + 1;
osal_memcpy(&obuf[1], &thsensor_cfg, sizeof(thsensor_cfg)-3);
olen = sizeof(thsensor_cfg)-3 + 1;
} else if (cmd == CMD_ID_CFS_DEF) { // Get/Set default sensor config
osal_memcpy(&thsensor_cfg.coef, &def_thcoef, sizeof(thsensor_cfg.coef));
flash_write_cfg(&thsensor_cfg.coef, EEP_ID_CFS, sizeof(thsensor_cfg.coef));
osal_memcpy(&obuf[1], &thsensor_cfg.coef, sizeof(thsensor_cfg.coef));
olen = sizeof(thsensor_cfg.coef) + 1;
osal_memset(&thsensor_cfg, 0, sizeof(thsensor_cfg));
init_sensor();
osal_memcpy(&obuf[1], &thsensor_cfg, sizeof(thsensor_cfg)-3);
olen = sizeof(thsensor_cfg)-3 + 1;
//---------- Debug commands (unsupported in different versions!):
@ -88,17 +88,19 @@ int cmd_parser(uint8_t * obuf, uint8_t * ibuf, uint32_t len) {
} else
olen = i + 3;
} else if (cmd == CMD_ID_MEM_RW && len > 4) { // Read/Write memory
uint8_t *p = (uint8_t *)(ibuf[1] | (ibuf[2]<<8) | (ibuf[3]<<16) | (ibuf[4]<<24));
uint8_t *p = (uint8_t *)
((uint32_t)(ibuf[1] | (ibuf[2]<<8) | (ibuf[3]<<16) | (ibuf[4]<<24)));
if(len > 5) {
len -= 5;
osal_memcpy(p, &ibuf[5], len);
} else
len = SEND_DATA_SIZE;
osal_memcpy(&obuf, &ibuf, 5);
osal_memcpy(obuf, ibuf, 5);
osal_memcpy(&obuf[5], p, len);
olen = len + 1 + 4;
} else if (cmd == CMD_ID_REG_RW && len > 4) { // Read/Write register
volatile uint32_t *p = (volatile uint32_t *)(ibuf[1] | (ibuf[2]<<8) | (ibuf[3]<<16) | (ibuf[4]<<24));
volatile uint32_t *p = (volatile uint32_t *)
((uint32_t)(ibuf[1] | (ibuf[2]<<8) | (ibuf[3]<<16) | (ibuf[4]<<24)));
uint32_t tmp;
if(len > 8) {
tmp = ibuf[5] | (ibuf[6]<<8) | (ibuf[7]<<16) | (ibuf[8]<<24);
@ -108,7 +110,7 @@ int cmd_parser(uint8_t * obuf, uint8_t * ibuf, uint32_t len) {
olen = 2;
}
tmp = *p;
osal_memcpy(&obuf, &ibuf, 5);
osal_memcpy(obuf, ibuf, 5);
osal_memcpy(&obuf[5], &tmp, 4);
olen = 1 + 4 + 4;
} else {

View file

@ -202,7 +202,7 @@ const ioinit_cfg_t ioInit[] = {
#if DEBUG_INFO || SDK_VER_RELEASE_ID != 0x03010102
hal_pwrmgr_RAM_retention(RET_SRAM0 | RET_SRAM1); // RET_SRAM0|RET_SRAM1|RET_SRAM2
#else
hal_pwrmgr_RAM_retention(RET_SRAM0); // RET_SRAM0|RET_SRAM1|RET_SRAM2
hal_pwrmgr_RAM_retention(RET_SRAM0 | RET_SRAM1); // RET_SRAM0|RET_SRAM1|RET_SRAM2
#endif
#endif

View file

@ -418,6 +418,7 @@ void new_cmd(void) {
attHandleValueNoti_t noti;
noti.handle = simpleProfileAttrTbl[CDM_DATA_ATTR_IDX].handle;
noti.len = cmd_parser(noti.value, cmd_in_buffer, cmd_in_len);
if(noti.len)
if(noti.len) {
GATT_Notification(gapRole_ConnectionHandle, &noti, FALSE );
}
}

View file

@ -145,10 +145,8 @@ extern const thsensor_coef_t def_thcoef_aht30;
typedef struct _thsensor_cfg_t {
thsensor_coef_t coef;
union {
uint32_t id;
uint16_t _id[2];
};
uint16_t mid;
uint16_t vid;
uint8_t i2c_addr;
} thsensor_cfg_t;

View file

@ -17,18 +17,14 @@
measured_data_t measured_data;
thsensor_cfg_t thsensor_cfg;
#if DEVICE == DEVICE_THB2
const thsensor_coef_t def_thcoef = {
const thsensor_coef_t def_thcoef_cht8310 = {
.temp_k = 25606,
.humi_k = 20000,
.temp_z = 0,
.humi_z = 0
};
#elif DEVICE == DEVICE_BTH01
const thsensor_coef_t def_thcoef = {
const thsensor_coef_t def_thcoef_cht8305 = {
.temp_k = 16500,
.humi_k = 10000,
.temp_z = -4000,
@ -42,8 +38,6 @@ const thsensor_coef_t def_thcoef_aht30 = {
.humi_z = 0
};
#endif
void init_i2c(void) {
hal_gpio_fmux_set(I2C_SCL, FMUX_IIC0_SCL);
hal_gpio_fmux_set(I2C_SDA, FMUX_IIC0_SDA);
@ -217,13 +211,13 @@ __ATTR_SECTION_XIP__ void init_sensor(void) {
send_i2c_byte(0, 0x06); // Reset command using the general call address
WaitMs(SENSOR_RESET_TIMEOUT_ms);
thsensor_cfg.i2c_addr = CHT8310_I2C_ADDR0;
if(!read_i2c_bytes(thsensor_cfg.i2c_addr, CHT8310_REG_MID, (uint8 *)&thsensor_cfg._id[0], 2) // 0x5959
&& !read_i2c_bytes(thsensor_cfg.i2c_addr, CHT8310_REG_VID, (uint8 *)&thsensor_cfg._id[1], 2)) { // 0x8215
if(!read_i2c_bytes(thsensor_cfg.i2c_addr, CHT8310_REG_MID, (uint8 *)&thsensor_cfg.mid, 2) // 0x5959
&& !read_i2c_bytes(thsensor_cfg.i2c_addr, CHT8310_REG_VID, (uint8 *)&thsensor_cfg.vid, 2)) { // 0x8215
if(adv_wrk.measure_interval_ms >= 5000) // > 5 sec
send_i2c_wreg(CHT8310_I2C_ADDR0, CHT8310_REG_CRT, 0x0300); // Set conversion ratio 5 sec
// else 1 sec
if(!thsensor_cfg.coef.temp_k) {
osal_memcpy(&thsensor_cfg.coef, &def_thcoef, sizeof(thsensor_cfg.coef));
osal_memcpy(&thsensor_cfg.coef, &def_thcoef_cht8310, sizeof(thsensor_cfg.coef));
}
} else
thsensor_cfg.i2c_addr = 0;
@ -235,8 +229,8 @@ __ATTR_SECTION_XIP__ void init_sensor(void) {
hal_gpio_write(GPIO_SPWR, 1);
#endif
thsensor_cfg.i2c_addr = CHT8305_I2C_ADDR0;
if((!read_i2c_bytes(thsensor_cfg.i2c_addr, CHT8310_REG_MID, (uint8 *)&thsensor_cfg._id[0], 2)) // 0x5959
&& (!read_i2c_bytes(thsensor_cfg.i2c_addr, CHT8310_REG_VID, (uint8 *)&thsensor_cfg._id[1], 2))) { // 0x8305
if((!read_i2c_bytes(thsensor_cfg.i2c_addr, CHT8310_REG_MID, (uint8 *)&thsensor_cfg.mid, 2)) // 0x5959
&& (!read_i2c_bytes(thsensor_cfg.i2c_addr, CHT8310_REG_VID, (uint8 *)&thsensor_cfg.vid, 2))) { // 0x8305
#if !USE_DEFAULT_SETS_SENSOR
// Soft reset command
send_i2c_wreg(thsensor_cfg.i2c_addr, CHT8305_REG_CFG,
@ -248,7 +242,7 @@ __ATTR_SECTION_XIP__ void init_sensor(void) {
// WaitMs(SENSOR_MEASURING_TIMEOUT_ms);
send_i2c_byte(thsensor_cfg.i2c_addr, CHT8305_REG_TMP); // start measure T/H
if(!thsensor_cfg.coef.temp_k) {
osal_memcpy(&thsensor_cfg.coef, &def_thcoef, sizeof(thsensor_cfg.coef));
osal_memcpy(&thsensor_cfg.coef, &def_thcoef_cht8305, sizeof(thsensor_cfg.coef));
}
} else {

View file

@ -161,7 +161,7 @@ static void set_serial_number(void)
efuse_read(EFUSE_BLOCK_0, temp_rd);
uint8_t *p = str_bin2hex(devInfoSerialNumber, (uint8_t *)&phy_flash.IdentificationID, 3);
*p++ = '-';
p = str_bin2hex(p, (uint8_t *)&thsensor_cfg.id, 4);
p = str_bin2hex(p, (uint8_t *)&thsensor_cfg.mid, 4);
*p++ = '-';
p = str_bin2hex(p, (uint8_t *)&temp_rd[0], 2);
}
@ -411,7 +411,7 @@ void SimpleBLEPeripheral_Init( uint8 task_id )
pGlobal_config[LL_SWITCH] |= CONN_CSA2_ALLOW;
llInitFeatureSetCodedPHY(TRUE);
#endif
llInitFeatureSet2MPHY(TRUE);
// llInitFeatureSet2MPHY(TRUE);
llInitFeatureSetDLE(TRUE);
#else
llInitFeatureSet2MPHY(FALSE);

View file

@ -0,0 +1,486 @@
<html class="telFlasherClass"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHY62x2-BTHome тест версия</title>
</head>
<body>
<script>
//BLE values
const FLASH_SIZE = 0x80000;
var bluetoothDevice, gattServer, otaCharacteristic, myCharacteristic;
//Firmware values
var firmwareArray = "",
startTime = 0,
flgRdFF = false,
blockCount = 0;
//Connection values
var connectTrys = 0;
var $ = function(id) { return document.getElementById(id);}
function resetVariables() {
busy = false;
gattServer = null;
Theservice = null;
otaCharacteristic = null;
myCharacteristic = null;
$('butReadFF').disabled = true;
$('butReadAddr').disabled = true;
$('butSave').disabled = true;
$('butStartDFU').disabled = true;
$('butWriteData').disabled = true;
$('butCmdData').disabled = true;
}
function handleError(error) {
addLog(error);
resetVariables();
if (connectTrys < 5) {
connectTrys++;
addLog("Переподключение " + connectTrys + " из " + 5);
doConnect();
} else {
addLog("Подключится не удалось!");
connectTrys = 0;
}
}
function onDisconnected() {
addLog('Disconnected.');
}
function connect() {
var deviceOptions = {
optionalServices: [0xfff0],
services: [0x180a, 0x181c, 0x181e, 0xfff0],
acceptAllDevices: true };
const namePrefix = $('namePrefix').value;
if (namePrefix) {
deviceOptions.acceptAllDevices = false;
deviceOptions.filters = namePrefix.split(",")
.map((x) => ({ namePrefix: x }));
} else {
deviceOptions.acceptAllDevices = false;
deviceOptions.filters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz_#@!*0123456789';,.<>{}[]"
.split("")
.map((x) => ({ namePrefix: x }));
}
if (bluetoothDevice != null) bluetoothDevice.gatt.disconnect();
resetVariables();
addLog("Поиск устройств");
connectTrys = 0;
navigator.bluetooth.requestDevice(deviceOptions).then(device => {
bluetoothDevice = device;
bluetoothDevice.addEventListener('gattserverdisconnected', onDisconnected);
addLog("Connecting to: " + bluetoothDevice.name);
doConnect();
}).catch(handleError);
}
function doConnect() {
bluetoothDevice.gatt.connect().then(server => {
addClog("Найден GATT сервер");
gattServer = server;
return gattServer.getPrimaryService(0xfff0);
}).then(service => {
addClog("Найден Main сервис");
Theservice = service;
return service.getCharacteristic(0xfff3);
}).then(characteristic => {
addClog("Найдена OTA характеристика");
otaCharacteristic = characteristic;
return Theservice.getCharacteristic(0xfff4);
}).then(characteristic => {
addClog("Найдена CMD характеристика");
myCharacteristic = characteristic;
myCharacteristic.readValue().then(value => {
if(value.byteLength >= 10)
addLog("DevCfg: "+dump8(value, value.byteLength));
//flash_buf = new Uint8Array(FLASH_SIZE);
myCharacteristic.addEventListener('characteristicvaluechanged', event => CustomBlkParse(event.target.value));
myCharacteristic.startNotifications().then(_ => {
let s = "Устройство подключено.";
addAlog(s);
$('butCmdData').disabled = false;
$('butReadFF').disabled = false;
$('butReadAddr').disabled = false;
$('butWriteData').disabled = false;
$('butStartDFU').disabled = false; })
})
}).catch(handleError);
}
function reConnect() {
if (bluetoothDevice != null) bluetoothDevice.gatt.disconnect();
resetVariables();
addLog("Reconnect");
connectTrys = 0;
doConnect();
}
function startDFU() {
addLog("Start DFU");
updateBegin();
}
function addLog(logTXT) {
console.log(logTXT)
var time = new Date().toLocaleTimeString();
var logString = time + ": " + logTXT;
$("log").innerHTML += logString + "<br>";
}
function addClog(logTXT) {
console.log(logTXT);
}
function addAlog(logTXT) {
addLog(logTXT);
setStatus(logTXT);
}
function clearLog() {
$("log").innerHTML = "";
}
function setStatus(status) {
// addClog("Status: " + status);
$("percent").innerHTML = "Статус: " + status;
}
function updateFail(err) {
let s = "Update error: " + err;
addAlog(s);
}
function decimalToHex(d, padding) {
var hex = Number(d).toString(16);
while (hex.length < 4) {
hex = "0" + hex;
}
return hex;
}
function hexToBytes(hex) {
for (var bytes = [], c = 0; c < hex.length; c += 2)
bytes.push(parseInt(hex.substr(c, 2), 16));
return new Uint8Array(bytes);
}
function bytesToHex(data) {
return new Uint8Array(data).reduce(function(memo, i) {
return memo + ("0" + i.toString(16)).slice(-2);
}, "");
}
function crc16_modbus(buffer) {
var crc = 0xFFFF;
var odd;
for (var i = 0; i < buffer.length; i++) {
crc = crc ^ buffer[i];
for (var j = 0; j < 8; j++) {
odd = crc & 0x0001;
crc = crc >> 1;
if (odd) {
crc = crc ^ 0xA001;
}
}
}
return crc;
};
function getHexCRC(data) {
var tempCRC = decimalToHex(crc16_modbus(hexToBytes(data)));
return tempCRC.substring(2, 4) + tempCRC.substring(0, 2);
}
function makeRandomID(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return bytesToHex(new TextEncoder("utf-8").encode(result));
}
function hex(number, len) {
var str = (number.toString(16)).toUpperCase();
while (str.length < len) str = '0' + str;
return str;
}
function hexToBytes(hex) {
for (var bytes = [], c = 0; c < hex.length; c += 2)
bytes.push(parseInt(hex.substr(c, 2), 16));
return new Uint8Array(bytes);
}
function dump(ar, len) {
let s = '';
for(let i=0; i < len; i++) {
s += hex(ar[i],2);
}
return s;
}
function dump8(ar, len) {
let s = '';
for(let i=0; i < len; i++) {
s += hex(ar.getUint8(i),2);
}
return s;
}
function hex2ascii(hexx) {
var hex = hexx.toString();
var str = '';
for (var i = 0;
(i < hex.length && hex.substr(i, 2) !== '00'); i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
return str;
}
window.onload = function() {
document.querySelector("#file").addEventListener("change", function() {
var reader = new FileReader();
reader.onload = function() {
firmwareArray = bytesToHex(this.result);
if(firmwareArray.substring(0,4)!="1234"){
alert("Выбранный файл не для PHY62x2 OTA!");
addLog("Выбранный файл не для PHY62x2 OTA!");
blockCount = 0;
firmwareArray = "";
return;
}
addLog("File was selected, size: " + firmwareArray.length / 2 + " bytes");
if (firmwareArray.length % 32 !== 0) { // pad last block to 16bytes
var padHex = "ffffffffffffffffffffffffffffffff";
firmwareArray += padHex.substr(0, 32 - firmwareArray.length % 32);
}
blockCount = firmwareArray.length / 32;
addLog("Count: " + blockCount);
}
if (this.files[0] != null)
reader.readAsArrayBuffer(this.files[0]);
else
addLog("Файл не выбран");
}, false);
$("butSave").onclick = function() {download(flash_buf, 'ff.bin', 'application/octet-stream;charset=utf-8');};
}
function updateBegin() {
if (blockCount <= 0) {
addLog("Не выбран файл!");
return;
}
setTimeout(function() {
otaCharSend("00ff").then(function(character) {
otaCharSend("01ff").then(function(character) {
setTimeout(function() {
startTime = new Date().getTime();
sendOTAblock(0);
}, 300);
}).catch(function(err) {
updateFail(err);
});
}).catch(function(err) {
updateFail(err);
});
}, 500);
}
function sendOTAblock(blockNr) {
if (blockNr >= blockCount) {
sendLastOTA();
return;
}
setStatus("Передан блок N: " + blockNr + " из " + blockCount + ", " + Math.floor(blockNr / (blockCount * 1.0) * 100) + "% успеха, время от старта " + (new Date().getTime() - startTime) / 1000.0 + "сек");
var blockNrString = getHexBLockCount(blockNr);
var blockString = blockNrString + firmwareArray.substring(blockNr * 32, blockNr * 32 + 32);
var blockCRC = getHexCRC(blockString);
otaCharSend(blockString + blockCRC).then(function(character) {
setTimeout(function() {
if ((blockNr + 1) % 8 == 0) {
otaCharacteristic.readValue().then(function(result) {
addClog('Чтение OTA');
sendOTAblock(blockNr + 1);
}).catch(function(err) {
updateFail(err);
});
} else {
sendOTAblock(blockNr + 1);
}
}, 0);
}).catch(function(err) {
updateFail(err);
});
}
function getHexBLockCount(count) {
var tempHEX = decimalToHex(count);
return tempHEX.substring(2, 4) + tempHEX.substring(0, 2);
}
function sendLastOTA() {
var data = "02ff" + getHexBLockCount(blockCount - 1) + getHexBLockCount(~(blockCount - 1) & 0xffff);
otaCharSend(data).then(function(character) {
addAlog("Прошивка завершена за " + (new Date().getTime() - startTime) / 1000 + " секунд");
}).catch(function(err) {
updateFail(err);
});
}
var otaCharSend = function(data) {
return new Promise(function(resolve, reject) {
//addClog("OTA: " + data);
otaCharacteristic.writeValue(hexToBytes(data)).then(function(character) {
resolve("ok");
}).catch(function(err) {
reject("some error while sending char data");
});
});
}
var mainCharSend = function(data, characteristic) {
return new Promise(function(resolve, reject) {
addClog("Send: " + data);
characteristic.writeValue(hexToBytes(data)).then(function(character) {
resolve("ok");
}).catch(function(err) {
reject("some error while sending char data");
});
});
}
function ReadAddr(addr) {
if(myCharacteristic) {
let blk = new Uint8Array([0xdb, addr&0xff, (addr>>8)&0xff, (addr>>16)&0xff, (addr>>24)&0xff]);
myCharacteristic.writeValue(blk).then(_ => {
startTime = new Date().getTime();
addAlog("Чтение 16 байт из 0x"+hex(addr,8)+"...");
});
}
}
function WriteAddr(addr, data) {
if(myCharacteristic) {
len = data.length;
if(len != 0 && len <= 16) {
let blk = new Uint8Array(len + 5);
blk.set([0xdb, addr&0xff, (addr>>8)&0xff, (addr>>16)&0xff, (addr>>24)&0xff]);
blk.set(data, 5);
console.log(blk);
addAlog("Запись "+len+" байт в 0x"+hex(addr,6)+"...");
myCharacteristic.writeValue(blk);
} else {
console.log(data);
addClog('Должно быть от 1 до 16 байт!');
}
}
}
function InfoReadAddr() {
if(myCharacteristic) {
let faddr = parseInt($('inputAddr').value, 16);
ReadAddr(faddr);
}
}
function WriteCmd(data) {
if(myCharacteristic) {
len = data.length;
if(len != 0 && len <= 20) {
let blk = new Uint8Array(data);
console.log(blk);
myCharacteristic.writeValue(blk);
} else {
console.log(data);
addClog('Должно быть от 1 до 20 байт!');
}
}
}
function WriteData() {
let addr = parseInt($('inputAddr').value, 16);
let data = hexToBytes($('inputData').value);
if(data.length != 0 && data.length <= 16)
WriteAddr(addr, data);
else
addClog('Должно быть от 1 до 16 hex байт!');
}
function CmdData() {
let data = hexToBytes($('inputCmdData').value);
if(data.length != 0 && data.length <= 20)
WriteCmd(data);
else
addClog('Должно быть от 1 до 20 hex байт!');
}
function CustomBlkParse(value) {
let len = value.byteLength;
if(len == 0) return;
len--; // size from cmd
let blkid = value.getUint8(0);
s = 'Ответ на команду id: '+hex(blkid,2)+' data: '+bytesToHex(value.buffer.slice(1));
addLog(s);
if(blkid == 0xdb && value.byteLength > 4) {
len -= 4;
let addr = value.getUint32(1,true);
let s = bytesToHex(value.buffer.slice(5), len);
$('inputData').value = s;
addLog(hex(addr,8)+':'+s);
setStatus("Считано "+len+" байт из 0x" + hex(addr,8));
} else
addClog('blk: '+dump8(value, value.byteLength));
}
var url;
function download(data, filename, type) {
var file = new Blob([data], {type: type});
if (window.navigator.msSaveOrOpenBlob) { // ie10+
window.navigator.msSaveOrOpenBlob(file, filename);
} else { // ff, chrome
url = URL.createObjectURL(file);
let a = document.createElement("a");
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function(){document.body.removeChild(a);window.URL.revokeObjectURL(url);},0);
URL.revokeObjectURL(url);
}
}
</script>
<big><big>PHY62x2-BTHome</big></big> <a href="https://github.com/pvvx/THB2">&#9432;</a><hr>
<button type="button" onclick="connect();">Соединение</button>
<button type="button" onclick="reConnect();">Переподключение</button><br><br>
<label for="namePrefix">Префикс названия устройств(а)</label>
<input type="text" id="namePrefix" value="" placeholder="THB, BT"><br><hr>
Выбор файла прошивки: <input type="file" accept=".bin" id="file"/><br>
<div id="percent">Состояние: Ожидание соединения с устройством</div>
<button type="button"id="butStartDFU" disabled="true" onclick="startDFU();">Старт программирования</button>
<br><hr>
<input type="button" id="butReadFF" onclick="StartReadFF()" disabled="true" value="Прочитать всю Flash">
<input type="button" id="butSave" disabled="true" value="Сохранить в файл"><br><hr>
Чтение и запись памяти:<br>
Адрес (hex): <input size="8" type="text" id="inputAddr" value="11000000" maxlength="8">
<input type="button" id="butReadAddr" onclick="InfoReadAddr()" disabled="true" value="Читать">
Данные (hex): <input size="40" type="text" id="inputData" value="?" maxlength="32">
<input type="button" id="butWriteData" onclick="WriteData()" disabled="true" value="Записать"><hr>
<input type="button" id="butCmdData" onclick="CmdData()" disabled="true" value="Команда">
<input size="40" type="text" id="inputCmdData" value="55" maxlength="40"><hr>
<button type="button" onclick="clearLog();">Очистить лог</button><br>
<div id="log"></div>
</body></html>

View file

@ -1 +1 @@
python3 rdwr_phy62x2.py -p COM11 -b 1000000 -r -e wh .\build\bthome_phy6222.hex
python3 rdwr_phy62x2.py -p COM11 -b 1000000 -r -e wh .\bin\THB2_v06.hex

View file

@ -1 +0,0 @@
python3 rdwr_phy62x2.py -p COM11 -b 1000000 -r -e wh .\bin\TestTHB2.hex

1
wr_bth01.cmd Normal file
View file

@ -0,0 +1 @@
python3 rdwr_phy62x2.py -p COM11 -e -r wh BTH01_v06.hex

View file

@ -1 +0,0 @@
python3 rdwr_phy62x2.py -p COM11 -e -r wh THB2_v05.hex

1
wr_thb2.cmd Normal file
View file

@ -0,0 +1 @@
python3 rdwr_phy62x2.py -p COM11 -e -r wh THB2_v06.hex