├── app └── mesh_common │ ├── _build │ ├── boot.link │ ├── makefile │ └── run.sh │ ├── app │ ├── app_common.c │ ├── app_common.h │ ├── app_factory_test.c │ ├── app_factory_test.h │ ├── app_mcu_protocol.c │ ├── app_mcu_protocol.h │ ├── app_rssi.c │ ├── app_rssi.h │ ├── app_uart.c │ ├── app_uart.h │ ├── app_unprov_beacon.c │ ├── app_unprov_beacon.h │ ├── tuya_node_init.c │ └── tuya_node_init.h │ ├── config.json │ └── package.json ├── doc ├── pics │ ├── telink_btd.png │ └── telink_flash_tools.jpg └── tools │ └── jq-win64.exe ├── includes ├── board │ ├── bal │ │ ├── tuya_element_cfg.h │ │ ├── tuya_sigmesh_hal.h │ │ ├── tuya_sigmesh_model.h │ │ ├── ty_fast_provision.h │ │ ├── ty_mesh_common.h │ │ └── ty_mesh_group.h │ ├── board.h │ ├── chip │ │ └── telink_sig_mesh_sdk │ │ │ └── sdk │ │ │ ├── drivers.h │ │ │ ├── drivers │ │ │ └── 8258 │ │ │ │ ├── adc.h │ │ │ │ ├── aes.h │ │ │ │ ├── analog.h │ │ │ │ ├── audio.h │ │ │ │ ├── bsp.h │ │ │ │ ├── clock.h │ │ │ │ ├── compiler.h │ │ │ │ ├── dfifo.h │ │ │ │ ├── dma.h │ │ │ │ ├── driver_8258.h │ │ │ │ ├── emi.h │ │ │ │ ├── flash.h │ │ │ │ ├── gpio.h │ │ │ │ ├── gpio_8258.h │ │ │ │ ├── gpio_default_8258.h │ │ │ │ ├── i2c.h │ │ │ │ ├── irq.h │ │ │ │ ├── lpc.h │ │ │ │ ├── pga.h │ │ │ │ ├── pm.h │ │ │ │ ├── pwm.h │ │ │ │ ├── qdec.h │ │ │ │ ├── random.h │ │ │ │ ├── register.h │ │ │ │ ├── register_8258.h │ │ │ │ ├── rf_drv.h │ │ │ │ ├── s7816.h │ │ │ │ ├── spi.h │ │ │ │ ├── spi_i.h │ │ │ │ ├── timer.h │ │ │ │ ├── uart.h │ │ │ │ └── watchdog.h │ │ │ ├── proj │ │ │ ├── common │ │ │ │ ├── array.h │ │ │ │ ├── assert.h │ │ │ │ ├── bit.h │ │ │ │ ├── breakpoint.h │ │ │ │ ├── compatibility.h │ │ │ │ ├── hash.h │ │ │ │ ├── list.h │ │ │ │ ├── log.h │ │ │ │ ├── log_id.h │ │ │ │ ├── macro_trick.h │ │ │ │ ├── mempool.h │ │ │ │ ├── mmem.h │ │ │ │ ├── printf.h │ │ │ │ ├── ringbuffer.h │ │ │ │ ├── selection_sort.h │ │ │ │ ├── static_assert.h │ │ │ │ ├── tstring.h │ │ │ │ ├── tutility.h │ │ │ │ ├── types.h │ │ │ │ └── utlist.h │ │ │ ├── config │ │ │ │ └── user_config.h │ │ │ ├── drivers │ │ │ │ ├── rf_pa.h │ │ │ │ ├── spi.h │ │ │ │ └── spi_i.h │ │ │ ├── mcu │ │ │ │ ├── clock_i.h │ │ │ │ ├── compiler.h │ │ │ │ ├── config.h │ │ │ │ ├── config_chip_type.h │ │ │ │ ├── dma.h │ │ │ │ ├── gpio.h │ │ │ │ ├── irq.h │ │ │ │ ├── irq_i.h │ │ │ │ ├── pin.h │ │ │ │ ├── putchar.h │ │ │ │ ├── pwm.h │ │ │ │ ├── register.h │ │ │ │ ├── watchdog.h │ │ │ │ └── watchdog_i.h │ │ │ ├── mcu_spec │ │ │ │ ├── adc_8263.h │ │ │ │ ├── adc_8266.h │ │ │ │ ├── adc_8267.h │ │ │ │ ├── anareg_8263.h │ │ │ │ ├── anareg_8886.h │ │ │ │ ├── gpio_8263.h │ │ │ │ ├── gpio_8266.h │ │ │ │ ├── gpio_8267.h │ │ │ │ ├── gpio_default_8263.h │ │ │ │ ├── gpio_default_8266.h │ │ │ │ ├── gpio_default_8267.h │ │ │ │ ├── pwm_8263.h │ │ │ │ ├── pwm_8266.h │ │ │ │ ├── pwm_8267.h │ │ │ │ ├── register_8263.h │ │ │ │ ├── register_8266.h │ │ │ │ └── register_8267.h │ │ │ └── tl_common.h │ │ │ ├── proj_lib │ │ │ ├── ble │ │ │ │ ├── att.h │ │ │ │ ├── ble_common.h │ │ │ │ ├── ble_smp.h │ │ │ │ ├── blt_config.h │ │ │ │ ├── crypt │ │ │ │ │ ├── aes │ │ │ │ │ │ └── aes_att.h │ │ │ │ │ ├── aes_ccm.h │ │ │ │ │ └── le_crypto.h │ │ │ │ ├── gap.h │ │ │ │ ├── hci │ │ │ │ │ ├── hci.h │ │ │ │ │ ├── hci_const.h │ │ │ │ │ ├── hci_event.h │ │ │ │ │ └── usb_desc.h │ │ │ │ ├── l2cap.h │ │ │ │ ├── ll │ │ │ │ │ ├── ll.h │ │ │ │ │ ├── ll_adv.h │ │ │ │ │ ├── ll_encrypt.h │ │ │ │ │ ├── ll_init.h │ │ │ │ │ ├── ll_master.h │ │ │ │ │ ├── ll_pm.h │ │ │ │ │ ├── ll_scan.h │ │ │ │ │ ├── ll_slave.h │ │ │ │ │ └── ll_whitelist.h │ │ │ │ ├── service │ │ │ │ │ ├── ble_ll_ota.h │ │ │ │ │ ├── device_information.h │ │ │ │ │ └── hids.h │ │ │ │ ├── trace.h │ │ │ │ └── uuid.h │ │ │ ├── mesh_crypto │ │ │ │ ├── aes_att.h │ │ │ │ ├── aes_cbc.h │ │ │ │ ├── constants.h │ │ │ │ ├── le_crypto.h │ │ │ │ ├── mesh_crypto.h │ │ │ │ ├── mesh_md5.h │ │ │ │ └── sha256_telink.h │ │ │ ├── pm.h │ │ │ ├── pm_8266.h │ │ │ ├── pm_8267.h │ │ │ ├── rf_drv.h │ │ │ ├── rf_drv_8266.h │ │ │ ├── rf_drv_8267.h │ │ │ └── sig_mesh │ │ │ │ ├── Test_case.h │ │ │ │ ├── app_mesh.h │ │ │ │ └── interface.h │ │ │ ├── stack │ │ │ ├── ble │ │ │ │ ├── attr │ │ │ │ │ └── gatt.h │ │ │ │ ├── ble.h │ │ │ │ ├── ble_common.h │ │ │ │ ├── ble_controller.h │ │ │ │ ├── blt_config.h │ │ │ │ ├── bqb │ │ │ │ │ └── bqb_ll.h │ │ │ │ ├── gap │ │ │ │ │ ├── gap.h │ │ │ │ │ └── gap_event.h │ │ │ │ ├── hci │ │ │ │ │ ├── hci.h │ │ │ │ │ ├── hci_cmd.h │ │ │ │ │ ├── hci_const.h │ │ │ │ │ └── hci_event.h │ │ │ │ ├── l2cap │ │ │ │ │ └── l2cap.h │ │ │ │ ├── ll │ │ │ │ │ ├── ll.h │ │ │ │ │ ├── ll_adv.h │ │ │ │ │ ├── ll_conn │ │ │ │ │ │ ├── ll_conn.h │ │ │ │ │ │ ├── ll_conn_csa.h │ │ │ │ │ │ ├── ll_conn_phy.h │ │ │ │ │ │ ├── ll_master.h │ │ │ │ │ │ └── ll_slave.h │ │ │ │ │ ├── ll_encrypt.h │ │ │ │ │ ├── ll_ext.h │ │ │ │ │ ├── ll_ext_scan.h │ │ │ │ │ ├── ll_init.h │ │ │ │ │ ├── ll_pm.h │ │ │ │ │ ├── ll_scan.h │ │ │ │ │ ├── ll_slave.h │ │ │ │ │ └── ll_whitelist.h │ │ │ │ ├── llms │ │ │ │ │ ├── llms.h │ │ │ │ │ ├── llms_adv.h │ │ │ │ │ ├── llms_init.h │ │ │ │ │ ├── llms_master.h │ │ │ │ │ ├── llms_scan.h │ │ │ │ │ ├── llms_slave.h │ │ │ │ │ ├── llms_slot.h │ │ │ │ │ └── trace.h │ │ │ │ ├── service │ │ │ │ │ └── device_information.h │ │ │ │ ├── smp │ │ │ │ │ ├── smp.h │ │ │ │ │ ├── smp_central.h │ │ │ │ │ ├── smp_const.h │ │ │ │ │ ├── smp_peripheral.h │ │ │ │ │ └── smp_storage.h │ │ │ │ ├── smpc │ │ │ │ │ ├── smp_ms.h │ │ │ │ │ └── smp_ms_storage.h │ │ │ │ └── trace.h │ │ │ └── ble_8278 │ │ │ │ ├── attr │ │ │ │ └── gatt.h │ │ │ │ ├── ble.h │ │ │ │ ├── ble_common.h │ │ │ │ ├── ble_controller.h │ │ │ │ ├── blt_config.h │ │ │ │ ├── gap │ │ │ │ ├── gap.h │ │ │ │ └── gap_event.h │ │ │ │ ├── hci │ │ │ │ ├── hci.h │ │ │ │ ├── hci_cmd.h │ │ │ │ ├── hci_const.h │ │ │ │ └── hci_event.h │ │ │ │ ├── l2cap │ │ │ │ └── l2cap.h │ │ │ │ ├── ll │ │ │ │ ├── ll.h │ │ │ │ ├── ll_adv.h │ │ │ │ ├── ll_conn │ │ │ │ │ ├── ll_conn.h │ │ │ │ │ ├── ll_conn_csa.h │ │ │ │ │ ├── ll_conn_phy.h │ │ │ │ │ ├── ll_master.h │ │ │ │ │ └── ll_slave.h │ │ │ │ ├── ll_encrypt.h │ │ │ │ ├── ll_ext.h │ │ │ │ ├── ll_init.h │ │ │ │ ├── ll_pm.h │ │ │ │ ├── ll_scan.h │ │ │ │ └── ll_whitelist.h │ │ │ │ └── trace.h │ │ │ ├── tl_common.h │ │ │ └── vendor │ │ │ ├── base │ │ │ ├── app.h │ │ │ ├── app_config_8258.h │ │ │ ├── app_config_8269.h │ │ │ └── app_config_8278.h │ │ │ └── common │ │ │ ├── app_beacon.h │ │ │ ├── app_health.h │ │ │ ├── app_heartbeat.h │ │ │ ├── app_provison.h │ │ │ ├── app_proxy.h │ │ │ ├── att_handle_index.h │ │ │ ├── blt_led.h │ │ │ ├── blt_soft_timer.h │ │ │ ├── cmd_interface.h │ │ │ ├── default_config.h │ │ │ ├── directed_forwarding.h │ │ │ ├── dual_mode_adapt.h │ │ │ ├── ev.h │ │ │ ├── fast_provision_model.h │ │ │ ├── generic_model.h │ │ │ ├── led_cfg.h │ │ │ ├── light.h │ │ │ ├── lighting_model.h │ │ │ ├── lighting_model_HSL.h │ │ │ ├── lighting_model_LC.h │ │ │ ├── lighting_model_xyL.h │ │ │ ├── mesh_common.h │ │ │ ├── mesh_config.h │ │ │ ├── mesh_fn.h │ │ │ ├── mesh_lpn.h │ │ │ ├── mesh_node.h │ │ │ ├── mesh_ota.h │ │ │ ├── mesh_property.h │ │ │ ├── mesh_test_cmd.h │ │ │ ├── mi_api │ │ │ ├── libs │ │ │ │ ├── common │ │ │ │ │ ├── crc32.h │ │ │ │ │ ├── mible_beacon.h │ │ │ │ │ ├── mible_beacon_internal.h │ │ │ │ │ ├── mible_crypto.h │ │ │ │ │ ├── mible_rxfer.h │ │ │ │ │ ├── queue.h │ │ │ │ │ └── tlv.h │ │ │ │ ├── cryptography │ │ │ │ │ ├── mi_crypto.h │ │ │ │ │ ├── mi_crypto_backend_mbedtls.h │ │ │ │ │ ├── mi_crypto_backend_msc.h │ │ │ │ │ ├── mi_crypto_backend_uECC.h │ │ │ │ │ ├── mi_mesh_otp.h │ │ │ │ │ ├── mi_mesh_otp_config.h │ │ │ │ │ └── mja1 │ │ │ │ │ │ ├── mjac_defs.h │ │ │ │ │ │ ├── mjac_utils.h │ │ │ │ │ │ └── mjac_wrapper.h │ │ │ │ ├── gatt_dfu │ │ │ │ │ ├── mible_dfu_auth.h │ │ │ │ │ ├── mible_dfu_flash.h │ │ │ │ │ └── mible_dfu_main.h │ │ │ │ ├── mesh_auth │ │ │ │ │ └── mible_mesh_auth.h │ │ │ │ ├── mi_config.h │ │ │ │ ├── mijia_profiles │ │ │ │ │ ├── mi_service_server.h │ │ │ │ │ └── stdio_service_server.h │ │ │ │ └── third_party │ │ │ │ │ ├── mbedtls │ │ │ │ │ ├── asn1.h │ │ │ │ │ ├── ccm.h │ │ │ │ │ ├── check_config.h │ │ │ │ │ ├── config.h │ │ │ │ │ ├── md.h │ │ │ │ │ ├── md_internal.h │ │ │ │ │ ├── sha256.h │ │ │ │ │ └── sha256_hkdf.h │ │ │ │ │ ├── micro-ecc │ │ │ │ │ ├── types.h │ │ │ │ │ ├── uECC.h │ │ │ │ │ ├── uECC_config.h │ │ │ │ │ └── uECC_vli.h │ │ │ │ │ └── pt │ │ │ │ │ ├── pt.h │ │ │ │ │ └── pt_misc.h │ │ │ ├── mijia_ble_api │ │ │ │ ├── mible_api.h │ │ │ │ ├── mible_log.h │ │ │ │ ├── mible_log_internal.h │ │ │ │ ├── mible_port.h │ │ │ │ ├── mible_trace.h │ │ │ │ └── mible_type.h │ │ │ ├── mijia_pub_proc.h │ │ │ └── telink_sdk_mible_api.h │ │ │ ├── myprintf.h │ │ │ ├── remote_prov.h │ │ │ ├── scene.h │ │ │ ├── scheduler.h │ │ │ ├── sdk_interface.h │ │ │ ├── sensors_model.h │ │ │ ├── system_time.h │ │ │ ├── time_model.h │ │ │ ├── user_ali.h │ │ │ ├── user_ali_time.h │ │ │ ├── user_config.h │ │ │ ├── user_proc.h │ │ │ ├── vendor_model.h │ │ │ └── version.h │ └── hal │ │ ├── hal_clock.h │ │ ├── hal_encrypt.h │ │ ├── hal_flash.h │ │ ├── hal_gpio.h │ │ ├── hal_hw_timer.h │ │ ├── hal_irq.h │ │ ├── hal_log.h │ │ ├── hal_pwm.h │ │ ├── hal_sleep.h │ │ ├── hal_sys.h │ │ ├── hal_types.h │ │ └── hal_uart.h └── components │ ├── ty_fifo.h │ ├── ty_gpio_base_test.h │ ├── ty_nv.h │ ├── ty_rssi_base_test.h │ ├── ty_string_op.h │ ├── ty_timer_event.h │ ├── ty_uart_cmd_server_for_factory_test.h │ ├── ty_uart_cmd_server_for_sig_mesh_uart_common.h │ └── ty_uart_cmd_server_for_sig_mesh_uart_common_storage.h ├── libs └── libtuya_ble_os.a ├── readme.md └── release.txt /app/mesh_common/_build/makefile: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # 全局变量 3 | ############################################################ 4 | PROJECT_ROOT := ../../.. 5 | 6 | INCS := -I$(PROJECT_ROOT)/includes/components \ 7 | -I$(PROJECT_ROOT)/includes/board \ 8 | -I$(PROJECT_ROOT)/includes/board/bal \ 9 | -I$(PROJECT_ROOT)/includes/board/hal \ 10 | -I$(PROJECT_ROOT)/includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common \ 11 | -I$(PROJECT_ROOT)/includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258 \ 12 | -I$(PROJECT_ROOT)/includes/board/chip/telink_sig_mesh_sdk/sdk \ 13 | -I../_build 14 | 15 | OBJS := 16 | C_SRCS := 17 | 18 | 19 | BIN = . 20 | LIBS := -ltuya_ble_os 21 | 22 | 23 | 24 | CC = tc32-elf-gcc 25 | CFLAGS = -ffunction-sections -fdata-sections -Wall -O2 -fpack-struct -fshort-enums -finline-small-functions -std=gnu99 -fshort-wchar -fms-extensions 26 | CMACROS = -DCHIP_TYPE=CHIP_TYPE_8258 -D__TUYA_PROJECT__=1 -DTLSR825X_SYS 27 | 28 | # Add inputs and outputs from these tool invocations to the build variables 29 | LST += \ 30 | 8258_mesh.lst \ 31 | 32 | FLASH_IMAGE += \ 33 | 8258_mesh.bin \ 34 | 35 | SIZEDUMMY += \ 36 | sizedummy \ 37 | 38 | 39 | -include app/subdir.mk 40 | 41 | 42 | ############################################################ 43 | # makefile 依赖 44 | ############################################################ 45 | # Main-build Target 46 | main-build: ble_lt_mesh.elf secondary-outputs 47 | 48 | # Tool invocations 49 | ble_lt_mesh.elf: $(OBJS) 50 | @echo 'Building target: $@' 51 | @echo 'Invoking: TC32 C Linker' 52 | tc32-elf-ld --gc-sections -L"$(PROJECT_ROOT)/libs" -T boot.link -o"ble_lt_mesh.elf" $(OBJS) $(LIBS) 53 | @echo 'Finished building target: $@' 54 | @echo ' ' 55 | 56 | 8258_mesh.lst: ble_lt_mesh.elf 57 | @echo 'Invoking: TC32 Create Extended Listing' 58 | tc32-elf-objdump -x -D -l -S ble_lt_mesh.elf >"8258_mesh.lst" 59 | @echo 'Finished building: $@' 60 | @echo ' ' 61 | 62 | 8258_mesh.bin: ble_lt_mesh.elf 63 | @echo 'Create Flash image (binary format)' 64 | tc32-elf-objcopy -O binary ble_lt_mesh.elf "8258_mesh.bin" 65 | @echo 'Finished building: $@' 66 | @echo ' ' 67 | 68 | sizedummy: ble_lt_mesh.elf 69 | @echo 'Invoking: Print Size' 70 | tc32-elf-size -t ble_lt_mesh.elf 71 | @echo 'Finished building: $@' 72 | @echo ' ' 73 | 74 | # Other Targets 75 | clean: 76 | -$(RM) $(FLASH_IMAGE) $(ELFS) $(OBJS) $(LST) $(SIZEDUMMY) ble_lt_mesh.elf 77 | -@echo ' ' 78 | 79 | pre-build: 80 | -"./getver.sh" 81 | -@echo ' ' 82 | 83 | secondary-outputs: $(LST) $(FLASH_IMAGE) $(SIZEDUMMY) 84 | -------------------------------------------------------------------------------- /app/mesh_common/app/app_common.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_common.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 25 Mar 2019 13:55:08 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_COMMON_H 9 | #define _APP_COMMON_H 10 | 11 | 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /app/mesh_common/app/app_factory_test.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_factory_test.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 12 Aug 2020 11:57:09 CST 6 | ************************************************************************/ 7 | #include "ty_uart_cmd_server_for_factory_test.h" 8 | #include "ty_gpio_base_test.h" 9 | #include "base_oem_config.h" 10 | 11 | static u8 if_enter_factory_test = 0; 12 | ty_uart_cmd_server_for_factory_test_params_s ty_uart_cmd_server_for_factory_test_params = { 13 | .is_need_fingerprint_check = 1, 14 | .is_need_get_pid_from_cloud = 0, 15 | .if_support_country_code = 0, 16 | .if_support_gpio_test_num = 1, 17 | 18 | .is_need_update_mac_in_flash = 1, 19 | .mac_address = 0x76000, 20 | 21 | .firmname = BUILD_FIRMNAME, 22 | .firmversion = FW_VERSION, 23 | }; 24 | void factory_test_enter_cb(void){ 25 | PR_DEBUG("ENTER\n"); 26 | if_enter_factory_test = 1; 27 | } 28 | 29 | u8 factory_test_rssi_test_start_cb(u8 *para, u8 len){ 30 | rssi_update_test_name(para, len); 31 | app_rssi_init(); 32 | } 33 | 34 | 35 | u8 factory_test_rssi_test_cb(void){ 36 | int rssi = 0; 37 | ty_rssi_base_test_stop(); 38 | if(ty_rssi_base_test_get_rssi_avg(&rssi) != -1){ 39 | if(rssi > 0 && rssi < 75){ 40 | return rssi; 41 | } 42 | } 43 | return 0; 44 | } 45 | void factory_test_reset_cb(void){ 46 | 47 | } 48 | 49 | //------------------------------------------------------------------------ 50 | void app_factory_test_init(void){ 51 | ty_uart_cmd_server_for_factory_test.init(&ty_uart_cmd_server_for_factory_test_params); 52 | ty_uart_cmd_server_for_factory_test.set_enter_callback(&factory_test_enter_cb); 53 | ty_uart_cmd_server_for_factory_test.set_gpio_test_callback(&ty_gpio_base_test_auto); 54 | ty_uart_cmd_server_for_factory_test.set_rssi_test_callback(&factory_test_rssi_test_cb); 55 | ty_uart_cmd_server_for_factory_test.set_rssi_test_start_callback(&factory_test_rssi_test_start_cb); 56 | ty_uart_cmd_server_for_factory_test.set_reset_callback(&factory_test_reset_cb); 57 | } 58 | 59 | int app_factory_test_cmd(u8 cmd, u8 *data, u8 len){ 60 | ty_uart_cmd_server_for_factory_test.receive_cmd(cmd,data,len); 61 | } 62 | 63 | int app_factory_test_run(void){ 64 | 65 | } 66 | 67 | int app_factory_test_if_enter(void){ 68 | return if_enter_factory_test; 69 | } 70 | -------------------------------------------------------------------------------- /app/mesh_common/app/app_factory_test.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_factory_test.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 12 Aug 2020 11:57:13 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_FACTORY_TEST_H 9 | #define _APP_FACTORY_TEST_H 10 | #endif 11 | -------------------------------------------------------------------------------- /app/mesh_common/app/app_mcu_protocol.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_mcu_protocol.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 12 Aug 2020 15:31:35 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_MCU_PROTOCOL_H 9 | #define _APP_MCU_PROTOCOL_H 10 | #endif 11 | -------------------------------------------------------------------------------- /app/mesh_common/app/app_rssi.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_rssi.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 27 Mar 2019 14:52:08 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_RSSI_H 9 | #define _APP_RSSI_H 10 | 11 | #include "board.h" 12 | 13 | extern void app_rssi_init(void); 14 | extern void app_rssi_run(u8 *adv, u8 adv_len, u8 *mac, int rssi); 15 | 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /app/mesh_common/app/app_uart.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_uart.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Tue 26 Feb 2019 22:29:40 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_UART_H 9 | #define _APP_UART_H 10 | 11 | #include "board.h" 12 | 13 | extern void app_uart_init(void); 14 | extern void app_uart_run(void); 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /app/mesh_common/app/app_unprov_beacon.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_unprov_beacon.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 25 Mar 2019 13:55:04 CST 6 | ************************************************************************/ 7 | #include "ty_nv.h" 8 | #include "tuya_node_init.h" 9 | 10 | 11 | #define NV_USER3_ITEM_PID 0 12 | #define PID_LEN 8 13 | 14 | 15 | void app_unprov_beacon_init(void){ 16 | u8 pid[PID_LEN]; 17 | 18 | if(NV_SUCCESS == ty_nv_user_data_read(NV_USER3_ITEM_PID, PID_LEN, pid)){ 19 | tuya_pid_set(pid); 20 | } 21 | } 22 | 23 | void app_unprov_beacon_update_pid(u8 *pid, u8 len){ 24 | if(len != PID_LEN)return; 25 | 26 | u8 pid_nv[PID_LEN]; 27 | 28 | if(NV_SUCCESS == ty_nv_user_data_read(NV_USER3_ITEM_PID, PID_LEN, pid_nv)){ 29 | if(memcmp(pid,pid_nv,PID_LEN) != 0){ 30 | if(NV_SUCCESS != ty_nv_user_data_write(NV_USER3_ITEM_PID, PID_LEN, pid)){ 31 | ty_nv_user_data_erase(); 32 | ty_nv_user_data_write(NV_USER3_ITEM_PID, PID_LEN, pid); 33 | } 34 | } 35 | }else{ 36 | if(NV_SUCCESS != ty_nv_user_data_write(NV_USER3_ITEM_PID, PID_LEN, pid)){ 37 | ty_nv_user_data_erase(); 38 | ty_nv_user_data_write(NV_USER3_ITEM_PID, PID_LEN, pid); 39 | } 40 | } 41 | 42 | tuya_pid_set(pid); 43 | } 44 | -------------------------------------------------------------------------------- /app/mesh_common/app/app_unprov_beacon.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_unprov_beacon.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 25 Mar 2019 13:55:08 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_UNPROV_BEACON_H 9 | #define _APP_UNPROV_BEACON_H 10 | 11 | #include "board.h" 12 | 13 | extern void app_unprov_beacon_init(void); 14 | extern void app_unprov_beacon_update_pid(u8 *pid, u8 len); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /app/mesh_common/app/tuya_node_init.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: tuya_node_init.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 25 Mar 2019 13:55:08 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_UNPROV_BEACON_H 9 | #define _APP_UNPROV_BEACON_H 10 | 11 | #include "board.h" 12 | 13 | extern void mesh_para_init(void); 14 | 15 | uint16_t tuya_get_mesh_category(void); 16 | uint8_t* tuya_get_pid(void); 17 | uint8_t tuya_get_is_key_or_pid(void); 18 | uint8_t tuya_get_if_need_pub_addr(void); 19 | uint16_t tuya_get_firmware_version(void); 20 | uint8_t tuya_get_power_reset_cnt(void); 21 | uint8_t tuya_get_power_reset_time(void); 22 | uint8_t tuya_get_power_reset_recover_time(void); 23 | 24 | void tuya_pid_set(uint8_t *pid); 25 | void tuya_mesh_category_set(uint16_t mesh_category); 26 | 27 | 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /app/mesh_common/config.json: -------------------------------------------------------------------------------- 1 | {"base_on":[]} 2 | -------------------------------------------------------------------------------- /app/mesh_common/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tlsr_825x_sig_mesh_common", 3 | "description": "mesh_base_test", 4 | "version": "1.1", 5 | "ic":"tlsr825x", 6 | "hardware":"TYBT3L", 7 | "build":{ 8 | "log":"0", 9 | "oem":"0", 10 | "json_config":"0" 11 | }, 12 | "directories": { 13 | "bin": "../../sdk/DEBUG/light.bin", 14 | "doc": "../../doc/", 15 | "sdk": "../../sdk/", 16 | "tools": "../../tools/" 17 | }, 18 | "product":{ 19 | "kind":"sig_mesh_light", 20 | "pid":"33lnzacq", 21 | "vendorid":"2000", 22 | "local_control":"1" 23 | }, 24 | "modules":{ 25 | }, 26 | "test":{ 27 | "gpio_test":{ 28 | "cases":[ 29 | { 30 | "pin_num":"8", 31 | "pin_array":"GPIO_PC2,GPIO_PC3,GPIO_PD2,GPIO_PB4,GPIO_PB5,GPIO_PC4,GPIO_PA0,GPIO_PC0", 32 | "pin_map":"2,2,1,3,3,1,4,4" 33 | }, 34 | { 35 | "pin_num":"7", 36 | "pin_array":"GPIO_PB4,GPIO_PD2,GPIO_PC1,GPIO_PC2,GPIO_PC0,GPIO_PB5,GPIO_PC3", 37 | "pin_map":"1,1,1,2,2,3,3" 38 | }, 39 | { 40 | "pin_num":"6", 41 | "pin_array":"GPIO_PC4,GPIO_PD2,GPIO_PC3,GPIO_PC2,GPIO_PB5,GPIO_PB4", 42 | "pin_map":"1,1,2,2,3,3" 43 | }, 44 | { 45 | "pin_num":"6", 46 | "pin_array":"GPIO_PD2,GPIO_PB5,GPIO_PC3,GPIO_PC2,GPIO_PC4,GPIO_PB4", 47 | "pin_map":"1,1,2,2,3,3" 48 | }, 49 | { 50 | "pin_num":"5", 51 | "pin_array":"GPIO_PB5,GPIO_PC2,GPIO_PD2,GPIO_PB4,GPIO_PC3", 52 | "pin_map":"2,1,1,2,1" 53 | }, 54 | { 55 | "pin_num":"3", 56 | "pin_array":"GPIO_PB5,GPIO_PC2,GPIO_PC3", 57 | "pin_map":"1,1,1" 58 | } 59 | ] 60 | } 61 | }, 62 | "git":{ 63 | "link":"ssh://git@code.registry.wgine.com:10023/bluetooth/telink_826x_mesh_node.git", 64 | "branch":"mesh_wifi_node_test" 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /doc/pics/telink_btd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/doc/pics/telink_btd.png -------------------------------------------------------------------------------- /doc/pics/telink_flash_tools.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/doc/pics/telink_flash_tools.jpg -------------------------------------------------------------------------------- /doc/tools/jq-win64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/doc/tools/jq-win64.exe -------------------------------------------------------------------------------- /includes/board/bal/ty_fast_provision.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ty_fast_provision.h 3 | * 4 | * Created on: 2020-05-28 5 | * Author: Joey 6 | */ 7 | 8 | #ifndef __TY_FAST_PROVISION_H 9 | #define __TY_FAST_PROVISION_H 10 | #include "ty_nv.h" 11 | #include "tuya_sigmesh_hal.h" 12 | 13 | #define FAST_PROVISION_TIMEOUT 60*1000*1000 14 | 15 | enum{ 16 | FAST_PROV_IDLE, 17 | FAST_PROV_INFO_GET, 18 | FAST_PROV_SET_ADDR, 19 | FAST_PROV_PROV_DATA_SET, 20 | FAST_PROV_CONFIRM, 21 | FAST_PROV_COMPLETE, 22 | FAST_PROV_TIME_OUT, 23 | }; 24 | 25 | 26 | typedef struct{ 27 | u16 category; 28 | u16 ele_addr; 29 | }dev_info_get_t; 30 | 31 | typedef struct{ 32 | u8 mac[6]; 33 | u16 category; 34 | }fast_prov_info_st; 35 | 36 | typedef struct{ 37 | fast_prov_net_data_t pro_data; 38 | fast_prov_app_key_t appkey_set; 39 | }fast_prov_net_info_t; 40 | 41 | typedef struct{ 42 | u16 ele_addr; 43 | u8 bind_kind; 44 | u8 mesh_pid[8]; 45 | u16 dev_ver; 46 | // u8 extra_info; 47 | } _PACKED_ fast_prov_mac_st; 48 | 49 | typedef struct{ 50 | u8 err_type; 51 | u8 err_rfu; 52 | }fast_prov_mac_err_st; 53 | 54 | typedef struct{ 55 | u8 get_mac_en; 56 | u32 rcv_op; 57 | u8 cur_sts; 58 | u8 last_sts; 59 | u8 pending; 60 | u16 delay; 61 | u32 start_tick; 62 | u32 revert_tick; 63 | fast_prov_net_info_t net_info; 64 | } _PACKED_ fast_prov_par_t; 65 | 66 | void ty_mesh_fast_prov_init(); 67 | void ty_mesh_fast_prov_proc(void); 68 | void tuya_mesh_fast_prov_en(u8 flag); 69 | uint8_t get_fast_prov_en_state(void); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /includes/board/bal/ty_mesh_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ty_mesh_common.h 3 | * 4 | * Created on: 2020-08-11 5 | * Author: Joey 6 | */ 7 | 8 | #ifndef __TY_MESH_COMMON_H 9 | #define __TY_MESH_COMMON_H 10 | 11 | 12 | 13 | void tuya_mesh_app_init(void); 14 | 15 | void tuya_mesh_main_run(void); 16 | 17 | void tuya_mesh_state_callback(mesh_state_t stat); 18 | 19 | void tuya_mesh_factory_reset(void); 20 | 21 | extern void mesh_app_init(void); 22 | extern void mesh_main_run(void); 23 | extern void mesh_factory_reset(void); 24 | extern void mesh_state_callback(mesh_state_t stat); 25 | 26 | 27 | 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /includes/board/bal/ty_mesh_group.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ty_mesh_group.h 3 | * 4 | * Created on: 2020-08-11 5 | * Author: Joey 6 | */ 7 | 8 | #ifndef __TY_MESH_GROUP_H 9 | #define __TY_MESH_GROUP_H 10 | 11 | int group_addr_sub_add(uint16_t mesh_addr, uint16_t group_addr); 12 | int group_addr_sub_del(uint16_t mesh_addr, uint16_t group_addr); 13 | uint16_t* group_addr_sub_list_get(); 14 | 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /includes/board/board.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: board.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 03 Jul 2019 21:49:02 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _BOARD_H 9 | #define _BOARD_H 10 | 11 | #include "hal_clock.h" 12 | #include "hal_flash.h" 13 | #include "hal_gpio.h" 14 | #include "hal_irq.h" 15 | #include "hal_log.h" 16 | #include "hal_sys.h" 17 | #include "hal_types.h" 18 | #include "hal_uart.h" 19 | 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file drivers.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author author@telink-semi.com; 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "proj/mcu/config.h" 26 | 27 | #if(__TL_LIB_8255__ || (MCU_CORE_TYPE == MCU_CORE_8255)) 28 | #include "drivers/8255/driver_8255.h" 29 | #elif(__TL_LIB_8258__ || (MCU_CORE_TYPE == MCU_CORE_8258)) 30 | #include "drivers/8258/driver_8258.h" 31 | #elif(MCU_CORE_TYPE == MCU_CORE_8278) 32 | #include "drivers/8278/driver_8278.h" 33 | #else 34 | #include "drivers/8258/driver_8258.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/adc.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/adc.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/analog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file analog.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * @par History: 21 | * 1.initial release(DEC. 26 2018) 22 | * 23 | * @version A001 24 | * 25 | *******************************************************************************************************/ 26 | 27 | #pragma once 28 | 29 | #include "compiler.h" 30 | 31 | 32 | /** 33 | * @brief This function serves to analog register read. 34 | * @param[in] addr - address need to be read. 35 | * @return the result of read. 36 | */ 37 | unsigned char analog_read(unsigned char addr); 38 | 39 | /** 40 | * @brief This function serves to analog register write. 41 | * @param[in] addr - address need to be write. 42 | * @param[in] v - the value need to be write. 43 | * @return none. 44 | */ 45 | void analog_write(unsigned char addr, unsigned char v); 46 | 47 | /** 48 | * @brief This function serves to analog register read. 49 | * @param[in] addr - address need to be read. 50 | * @param[in] *buff - the value need to be read. 51 | * @param[in] len - the length of read value. 52 | * @return none. 53 | */ 54 | void analog_read_buff(unsigned char addr, unsigned char *buff, int len); 55 | 56 | /** 57 | * @brief This function serves to analog register write. 58 | * @param[in] addr - address need to be write. 59 | * @param[in] *buff - the value need to be write. 60 | * @param[in] len - the length of write value. 61 | * @return none. 62 | */ 63 | void analog_write_buff(unsigned char addr, unsigned char *buff, int len); 64 | 65 | 66 | //#define WriteAnalogReg analog_write 67 | //#define ReadAnalogReg analog_read 68 | 69 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/compiler.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file compiler.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * @par History: 21 | * 1.initial release(DEC. 26 2018) 22 | * 23 | * @version A001 24 | * 25 | *******************************************************************************************************/ 26 | 27 | #include "proj/mcu/compiler.h" 28 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/driver_8258.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file driver_8258.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | 25 | 26 | #include "drivers/8258/bsp.h" 27 | #include "drivers/8258/aes.h" 28 | #include "drivers/8258/analog.h" 29 | #include "drivers/8258/compiler.h" 30 | #include "drivers/8258/register.h" 31 | #include "drivers/8258/gpio.h" 32 | #include "drivers/8258/pwm.h" 33 | #include "drivers/8258/irq.h" 34 | #include "drivers/8258/clock.h" 35 | #include "drivers/8258/random.h" 36 | #include "drivers/8258/flash.h" 37 | #include "drivers/8258/rf_drv.h" 38 | #include "drivers/8258/pm.h" 39 | #include "drivers/8258/audio.h" 40 | #include "drivers/8258/adc.h" 41 | #include "drivers/8258/i2c.h" 42 | #include "drivers/8258/spi.h" 43 | #include "drivers/8258/uart.h" 44 | #include "drivers/8258/register.h" 45 | #include "drivers/8258/watchdog.h" 46 | #include "drivers/8258/register.h" 47 | #include "drivers/8258/dfifo.h" 48 | #include "drivers/8258/dma.h" 49 | #include "drivers/8258/emi.h" 50 | #include "drivers/8258/timer.h" 51 | 52 | #include "drivers/8258/s7816.h" 53 | #include "drivers/8258/qdec.h" 54 | #include "drivers/8258/lpc.h" 55 | 56 | //#include "drivers/8258/rf_pa.h" 57 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/gpio.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file gpio.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "proj/mcu/config.h" 26 | #include "gpio_default_8258.h" 27 | #include "gpio_8258.h" 28 | 29 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/random.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file random.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | /** 27 | * @brief This function performs to initials random generator post. 28 | * @param[in] none. 29 | * @return none. 30 | */ 31 | void random_generator_init(void); 32 | 33 | /** 34 | * @brief This function performs to get one random number 35 | * @param[in] none. 36 | * @return the value of one random number. 37 | */ 38 | unsigned int rand(void); 39 | 40 | unsigned int myrand(void); 41 | 42 | /** 43 | * @brief This function performs to get a serial of random number. 44 | * @param[in] len- the length of random number 45 | * @param[in] data - the first address of buffer store random number in 46 | * @return the result of a serial of random number. 47 | */ 48 | void generateRandomNum(int len, unsigned char *data); 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/register.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file register.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | 25 | 26 | #include "register_8258.h" 27 | 28 | 29 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/rf_drv.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/rf_drv.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/drivers/8258/watchdog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file watchdog.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author Driver Group 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * @par History: 21 | * 1.initial release(DEC. 26 2018) 22 | * 23 | * @version A001 24 | * 25 | *******************************************************************************************************/ 26 | 27 | #pragma once 28 | 29 | 30 | #include "register.h" 31 | 32 | /** 33 | * @brief This function set the seconds period.It is likely with WD_SetInterval. 34 | * Just this function calculate the value to set the register automatically . 35 | * @param[in] period_s - The seconds to set. unit is second 36 | * @return none 37 | */ 38 | extern void wd_set_interval_ms(unsigned int period_ms,unsigned long int tick_per_ms); 39 | 40 | /** 41 | * @brief start watchdog. ie enable watchdog 42 | * @param[in] none 43 | * @return none 44 | */ 45 | static inline void wd_start(void){ 46 | BM_SET(reg_tmr_ctrl, FLD_TMR2_EN); 47 | BM_SET(reg_tmr_ctrl, FLD_TMR_WD_EN); 48 | } 49 | /** 50 | * @brief stop watchdog. ie disable watchdog 51 | * @param[in] none 52 | * @return none 53 | */ 54 | static inline void wd_stop(void){ 55 | BM_CLR(reg_tmr_ctrl, FLD_TMR_WD_EN); 56 | } 57 | 58 | /** 59 | * @brief clear watchdog. 60 | * @param[in] none 61 | * @return none 62 | */ 63 | static inline void wd_clear(void) 64 | { 65 | reg_tmr_sta = FLD_TMR_STA_WD; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/bit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/bit.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/log.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file log.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "log_id.h" 26 | #include "printf.h" 27 | #include "compatibility.h" 28 | 29 | 30 | #ifndef LOG_IN_RAM 31 | #define LOG_IN_RAM 0 32 | #endif 33 | 34 | #define LOG_MASK_BEGIN 0x40 35 | #define LOG_MASK_END 0x00 36 | #define LOG_MASK_TGL 0xC0 37 | #define LOG_MASK_DAT 0x80 38 | 39 | static inline void swire2usb_init (void) { 40 | U8_SET(0x800128, 0x00); 41 | U8_SET(0x80012d, 0); 42 | U8_SET(0x80013b, 32); 43 | } 44 | 45 | static inline void usb_log_init (void) { 46 | U8_SET(0x80013c, 0x40); 47 | U8_SET(0x80013d, 0x09); 48 | } 49 | 50 | #if (__LOG_RT_ENABLE__) 51 | void log_write_data(int id, int type, u32 dat); 52 | void log_task_begin(int id); 53 | void log_task_end(int id); 54 | void log_event(int id); 55 | void log_data(int id, u32 dat); 56 | 57 | #define LOG_TICK(id,e) do{log_task_begin(id); e; log_task_end(id);}while(0) 58 | 59 | #define LOG(x, s,...) printf("(%s:%d)" x "\r\n" , __FUNCTION__, __LINE__, ## s) 60 | 61 | #else 62 | #define log_write_data(id, type, dat) 63 | #define log_task_begin(id) 64 | #define log_task_end(id) 65 | #define log_event(id) 66 | #define log_data(id, dat) 67 | #define LOG_TICK(id,e) do{e;}while (0) 68 | 69 | #define LOG(x, s,...) 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/mempool.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file mempool.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../common/types.h" 26 | 27 | typedef struct mem_block_t 28 | { 29 | struct mem_block_t* next_block; 30 | char data[4]; // must 4 or 8 aligned, padding 31 | }mem_block_t; 32 | 33 | typedef struct mem_pool_t 34 | { 35 | mem_block_t* free_list; 36 | }mem_pool_t; 37 | 38 | #define MEMPOOL_ALIGNMENT 4 39 | #define MEMPOOL_ITEMSIZE_2_BLOCKSIZE(s) ((s + (MEMPOOL_ALIGNMENT - 1)) & ~(MEMPOOL_ALIGNMENT-1)) 40 | 41 | #define MEMPOOL_DECLARE(pool_name, pool_mem, itemsize, itemcount) \ 42 | mem_pool_t pool_name; \ 43 | u8 pool_mem[MEMPOOL_ITEMSIZE_2_BLOCKSIZE(itemsize) * itemcount]; 44 | 45 | mem_pool_t* mempool_init(mem_pool_t* pool, void* mem, int itemsize, int itemcount); 46 | void* mempool_alloc(mem_pool_t* pool); 47 | void mempool_free(mem_pool_t* pool, void* p); 48 | mem_block_t* mempool_header(char* pd); 49 | 50 | 51 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/mmem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/mmem.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/printf.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file printf.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | #if(!__PROJECT_8263_BLE_MODULE__) 25 | #ifdef WIN32 26 | #include 27 | #else 28 | #include 29 | 30 | int my_printf(const char *fmt, ...); 31 | int my_sprintf(char* s, const char *fmt, ...); 32 | 33 | int my_printf_uart(const char *format,...); 34 | int my_printf_uart_hexdump(unsigned char *p_buf,int len ); 35 | int print(char **out, const char *format, va_list args) ; 36 | int printf_Bin2Text (char *lpD, int lpD_len_max, char *lpS, int n); 37 | u32 get_len_Bin2Text(u32 buf_len); 38 | 39 | int app_printf(const char *format, ...); 40 | 41 | 42 | #define printf my_printf 43 | #define sprintf my_sprintf 44 | 45 | #endif 46 | #endif 47 | 48 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/selection_sort.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file selection_sort.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | void selection_sort_char(unsigned char * arr, int size); 26 | void selection_sort_int(unsigned int * arr, int size); 27 | 28 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/static_assert.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file static_assert.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | // static assertion. evaluate at compile time. It is very useful like, STATIC_ASSERT(sizeof(a) == 5); 26 | 27 | // #define STATIC_ASSERT(expr) { char static_assertion[(expr) ? 1 : -1]; ((void) static_assertion); } // (void) array; to remove compiler unused variable warning 28 | 29 | // more complicated version canbe used anywhere in the source 30 | #define STATIC_ASSERT_M(COND,MSG) typedef char static_assertion_##MSG[(!!(COND))*2-1] 31 | // token pasting madness: 32 | #define STATIC_ASSERT3(X,L) STATIC_ASSERT_M(X,static_assertion_at_line_##L) 33 | #define STATIC_ASSERT2(X,L) STATIC_ASSERT3(X,L) 34 | 35 | #define STATIC_ASSERT(X) STATIC_ASSERT2(X,__LINE__) 36 | 37 | #define STATIC_ASSERT_POW2(expr) STATIC_ASSERT(!((expr) & ((expr)-1))) // assert expr is 2**N 38 | #define STATIC_ASSERT_EVEN(expr) STATIC_ASSERT(!((expr) & 1)) 39 | #define STATIC_ASSERT_ODD(expr) STATIC_ASSERT(((expr) & 1)) 40 | #define STATIC_ASSERT_INT_DIV(a, b) STATIC_ASSERT((a) / (b) * (b) == (a)) 41 | 42 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/tutility.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/tutility.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/common/types.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file types.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | 24 | #pragma once 25 | #include /* size_t */ 26 | #include 27 | typedef unsigned char u8 ; 28 | typedef signed char s8; 29 | 30 | typedef unsigned short int u16; 31 | typedef signed short int s16; 32 | 33 | typedef int s32; 34 | typedef unsigned int u32; 35 | 36 | typedef long long s64; 37 | typedef unsigned long long u64; 38 | 39 | typedef unsigned char word8; 40 | typedef unsigned short word16; 41 | typedef unsigned long word32; 42 | 43 | typedef unsigned char uint8_t; 44 | typedef unsigned short uint16_t; 45 | typedef unsigned long uint32_t; 46 | 47 | #ifndef NULL 48 | #define NULL 0 49 | #endif 50 | 51 | #ifndef __cplusplus 52 | //typedef u8 bool; 53 | 54 | #ifndef FALSE 55 | #define FALSE 0 56 | #endif 57 | #ifndef TRUE 58 | #define TRUE (!FALSE) 59 | #endif 60 | 61 | //#define false FALSE 62 | //#define true TRUE 63 | 64 | #endif 65 | 66 | // There is no way to directly recognise whether a typedef is defined 67 | // http://stackoverflow.com/questions/3517174/how-to-check-if-a-datatype-is-defined-with-typedef 68 | #ifdef __GNUC__ 69 | typedef u16 wchar_ts; 70 | #endif 71 | 72 | #define U32_MAX ((u32)0xffffffff) 73 | #define U16_MAX ((u16)0xffff) 74 | #define U8_MAX ((u8)0xff) 75 | #define U31_MAX ((u32)0x7fffffff) 76 | #define U15_MAX ((u16)0x7fff) 77 | #define U7_MAX ((u8)0x7f) 78 | 79 | #define SUCCESS 0x00 80 | #define FAILURE 0x01 81 | 82 | typedef u32 UTCTime; 83 | typedef u32 arg_t; 84 | typedef u32 status_t; 85 | 86 | 87 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/config/user_config.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file user_config.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../vendor/common/user_config.h" 26 | 27 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/drivers/rf_pa.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file rf_pa.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef BLT_PA_H_ 24 | #define BLT_PA_H_ 25 | 26 | #include "../tl_common.h" 27 | 28 | 29 | 30 | // for not 826x,PA pin use integrated RF synthesizer, refer to RF_LNARxPinDef and RF_PATxPinDef for pa pin!!! 31 | #ifndef PA_TXEN_PIN 32 | #define PA_TXEN_PIN GPIO_PC7 33 | #endif 34 | 35 | #ifndef PA_RXEN_PIN 36 | #define PA_RXEN_PIN GPIO_PC6 37 | #endif 38 | 39 | 40 | 41 | #define PA_TYPE_OFF 0 42 | #define PA_TYPE_TX_ON 1 43 | #define PA_TYPE_RX_ON 2 44 | 45 | 46 | typedef void (*rf_pa_callback_t)(int type); 47 | extern rf_pa_callback_t blc_rf_pa_cb; 48 | 49 | 50 | 51 | void rf_pa_init(void); 52 | 53 | 54 | #endif /* BLT_PA_H_ */ 55 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/drivers/spi.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file spi.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../common/types.h" 26 | #if(MCU_CORE_TYPE == MCU_CORE_8258) 27 | #include "drivers/8258/spi.h" 28 | #elif(MCU_CORE_TYPE == MCU_CORE_8278) 29 | #include "drivers/8278/spi.h" 30 | #else 31 | 32 | void spi_write(u8 d); 33 | u8 spi_read(); 34 | 35 | typedef void (*spi_callback_func)(u8 *); 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/drivers/spi_i.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file spi_i.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #include "proj/mcu/config.h" 23 | #include "../config/user_config.h" 24 | #include "../mcu/gpio.h" 25 | #include "../mcu/register.h" 26 | #ifndef WIN32 27 | #if(__TL_LIB_8258__ || MCU_CORE_TYPE == MCU_CORE_8258) 28 | #include "drivers/8258/spi_i.h" 29 | #elif(MCU_CORE_TYPE == MCU_CORE_8278) 30 | #include "drivers/8278/spi_i.h" 31 | #else 32 | 33 | // use static inline, because, spi flash code must reside in memory.. 34 | // these code may be embedd in flash code 35 | 36 | static inline void mspi_wait(void){ 37 | while(reg_master_spi_ctrl & FLD_MASTER_SPI_BUSY) 38 | ; 39 | } 40 | 41 | static inline void mspi_high(void){ 42 | reg_master_spi_ctrl = FLD_MASTER_SPI_CS; 43 | } 44 | 45 | static inline void mspi_low(void){ 46 | reg_master_spi_ctrl = 0; 47 | } 48 | 49 | static inline u8 mspi_get(void){ 50 | return reg_master_spi_data; 51 | } 52 | 53 | static inline void mspi_write(u8 c){ 54 | reg_master_spi_data = c; 55 | } 56 | 57 | static inline void mspi_ctrl_write(u8 c){ 58 | reg_master_spi_ctrl = c; 59 | } 60 | 61 | static inline u8 mspi_read(void){ 62 | mspi_write(0); // dummy, issue clock 63 | mspi_wait(); 64 | return mspi_get(); 65 | } 66 | #endif 67 | #endif 68 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/config.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file config.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #define CHIP_PACKAGE_QFN64 1 26 | #define CHIP_PACKAGE_QFN48 2 27 | #define CHIP_PACKAGE_QFN40 3 28 | #define CHIP_PACKAGE_QFN32 4 29 | 30 | #ifndef CHIP_PACKAGE 31 | #define CHIP_PACKAGE CHIP_PACKAGE_QFN64 32 | #endif 33 | 34 | #include "config_chip_type.h" 35 | 36 | 37 | #ifndef CHIP_TYPE 38 | #define CHIP_TYPE 1000 39 | #endif 40 | 41 | #ifndef CHIP_8366_A1 42 | #define CHIP_8366_A1 1 43 | #endif 44 | 45 | #define MCU_CORE_8266 1 46 | #define MCU_CORE_8366 2 47 | #define MCU_CORE_8368 3 48 | #define MCU_CORE_8267 4 49 | #define MCU_CORE_8263 5 50 | #define MCU_CORE_8261 6 51 | #define MCU_CORE_8269 7 52 | #define MCU_CORE_8258 8 53 | #define MCU_CORE_8278 9 54 | 55 | #if(CHIP_TYPE == CHIP_TYPE_8266) 56 | #define MCU_CORE_TYPE MCU_CORE_8266 57 | #elif(CHIP_TYPE == CHIP_TYPE_8267) 58 | #define MCU_CORE_TYPE MCU_CORE_8267 59 | #elif(CHIP_TYPE == CHIP_TYPE_8366) 60 | #define MCU_CORE_TYPE MCU_CORE_8366 61 | #elif(CHIP_TYPE == CHIP_TYPE_8368) 62 | #define MCU_CORE_TYPE MCU_CORE_8368 63 | #elif(CHIP_TYPE == CHIP_TYPE_8263) 64 | #define MCU_CORE_TYPE MCU_CORE_8263 65 | #elif(CHIP_TYPE == CHIP_TYPE_8261) 66 | #define MCU_CORE_TYPE MCU_CORE_8261 67 | #elif(CHIP_TYPE == CHIP_TYPE_8269) 68 | #define MCU_CORE_TYPE MCU_CORE_8269 69 | #elif(CHIP_TYPE == CHIP_TYPE_8258) 70 | #define MCU_CORE_TYPE MCU_CORE_8258 71 | #elif(CHIP_TYPE == CHIP_TYPE_8278) 72 | #define MCU_CORE_TYPE MCU_CORE_8278 73 | #else 74 | #define MCU_CORE_TYPE 1000 75 | #endif 76 | 77 | 78 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/config_chip_type.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file config_chip_type.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #define CHIP_TYPE_8266 1 26 | #define CHIP_TYPE_8366 2 27 | #define CHIP_TYPE_8368 3 28 | #define CHIP_TYPE_8267 4 29 | #define CHIP_TYPE_8263 5 30 | #define CHIP_TYPE_8261 6 31 | #define CHIP_TYPE_8269 7 32 | #define CHIP_TYPE_8258 8 33 | #define CHIP_TYPE_8278 9 34 | 35 | 36 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/dma.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file dma.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../mcu/register.h" 26 | #ifndef WIN32 27 | static inline void dma_init(){ 28 | reg_dma_chn_irq_msk = 29 | (RF_RX_USE_DMA_IRQ ? FLD_DMA_CHN_RF_RX : 0) | (RF_TX_USE_DMA_IRQ ? FLD_DMA_CHN_RF_TX : 0); 30 | } 31 | 32 | static inline void dma_irq_clear(){ 33 | reg_dma_chn_irq_msk = 0; 34 | } 35 | 36 | static inline void dma_channel_enable_all(){ 37 | reg_dma_chn_en = 0xff; 38 | } 39 | 40 | static inline void dma_channel_disable_all(){ 41 | reg_dma_chn_en = 0; 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/gpio.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file gpio.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | enum{ 27 | GPIO_DIR_IN = 0, 28 | GPIO_DIR_OUT = 1 29 | }; 30 | 31 | // do not use enum, because we use this in preprocessor diretive, #if 32 | #define AS_GPIO 0 33 | #define AS_MSPI 1 34 | #define AS_SWIRE 2 35 | #define AS_UART 3 36 | #define AS_PWM 4 37 | #define AS_I2C 5 38 | #define AS_SPI 6 39 | #define AS_ETH_MAC 7 40 | #define AS_I2S 8 41 | #define AS_SDM 9 42 | #define AS_DMIC 10 43 | #define AS_USB 11 44 | #define AS_SWS 12 45 | #define AS_SWM 13 46 | #define AS_TEST 14 47 | #define AS_ADC 15 48 | 49 | #include "config.h" 50 | #include "../common/static_assert.h" 51 | 52 | #if(__TL_LIB_8266__ || MCU_CORE_TYPE == MCU_CORE_8266) 53 | #include "../mcu_spec/gpio_default_8266.h" 54 | #include "../mcu_spec/gpio_8266.h" 55 | #elif(__TL_LIB_8267__ || MCU_CORE_TYPE == MCU_CORE_8267 || \ 56 | __TL_LIB_8261__ || MCU_CORE_TYPE == MCU_CORE_8261 || \ 57 | __TL_LIB_8269__ || MCU_CORE_TYPE == MCU_CORE_8269 ) 58 | #include "../mcu_spec/gpio_default_8267.h" 59 | #include "../mcu_spec/gpio_8267.h" 60 | #elif(__TL_LIB_8258__ || MCU_CORE_TYPE == MCU_CORE_8258) 61 | #include "drivers/8258/gpio.h" 62 | #elif(MCU_CORE_TYPE == MCU_CORE_8278) 63 | #include "drivers/8278/gpio.h" 64 | #elif(__TL_LIB_8366__ || MCU_CORE_TYPE == MCU_CORE_8366) 65 | #include "../mcu_spec/gpio_default_8366.h" 66 | #include "../mcu_spec/gpio_8366.h" 67 | #elif(__TL_LIB_8263__ || MCU_CORE_TYPE == MCU_CORE_8263) 68 | #include "../mcu_spec/gpio_default_8263.h" 69 | #include "../mcu_spec/gpio_8263.h" 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/irq.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file irq.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/pin.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file pin.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/putchar.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file putchar.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #ifndef WIN32 26 | 27 | int putchar(int c); 28 | 29 | #endif 30 | 31 | 32 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/pwm.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file pwm.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef PWM_H_ 24 | #define PWM_H_ 25 | #include "config.h" 26 | 27 | #if(__TL_LIB_8266__ || MCU_CORE_TYPE == MCU_CORE_8266) 28 | #include "../mcu_spec/pwm_8266.h" 29 | #elif(__TL_LIB_8267__ || MCU_CORE_TYPE == MCU_CORE_8267 || \ 30 | __TL_LIB_8261__ || MCU_CORE_TYPE == MCU_CORE_8261 || \ 31 | __TL_LIB_8269__ || MCU_CORE_TYPE == MCU_CORE_8269 ) 32 | #include "../mcu_spec/pwm_8267.h" 33 | #elif(__TL_LIB_8258__ || MCU_CORE_TYPE == MCU_CORE_8258 ) 34 | #include "drivers/8258/pwm.h" 35 | #elif(MCU_CORE_TYPE == MCU_CORE_8278 ) 36 | #include "drivers/8278/pwm.h" 37 | #elif(__TL_LIB_8263__ || MCU_CORE_TYPE == MCU_CORE_8263) 38 | #include "../mcu_spec/pwm_8263.h" 39 | #endif 40 | 41 | 42 | #endif /* PWM_H_ */ 43 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/register.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file register.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | #include "config.h" 24 | 25 | #if(__TL_LIB_8266__ || MCU_CORE_TYPE == MCU_CORE_8266) 26 | #include "../mcu_spec/register_8266.h" 27 | #elif(__TL_LIB_8267__ || MCU_CORE_TYPE == MCU_CORE_8267 || \ 28 | __TL_LIB_8261__ || MCU_CORE_TYPE == MCU_CORE_8261 || \ 29 | __TL_LIB_8269__ || MCU_CORE_TYPE == MCU_CORE_8269 ) 30 | #include "../mcu_spec/register_8267.h" 31 | #elif (__TL_LIB_8258__ || MCU_CORE_TYPE == MCU_CORE_8258 ) 32 | #include "../../drivers/8258/register.h" 33 | #elif(MCU_CORE_TYPE == MCU_CORE_8278 ) 34 | #include "drivers/8278/register.h" 35 | #elif(__TL_LIB_8366__ || MCU_CORE_TYPE == MCU_CORE_8366) 36 | #include "../mcu_spec/register_8366.h" 37 | #elif(__TL_LIB_8263__ || MCU_CORE_TYPE == MCU_CORE_8263) 38 | #include "../mcu_spec/register_8263.h" 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/watchdog.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file watchdog.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | 26 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu/watchdog_i.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file watchdog_i.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #include "proj/mcu/config.h" 24 | #include "register.h" 25 | 26 | #if(__TL_LIB_8258__ || MCU_CORE_TYPE == MCU_CORE_8258) 27 | #include "drivers/8258/watchdog.h" 28 | #elif(MCU_CORE_TYPE == MCU_CORE_8278) 29 | #include "drivers/8278/watchdog.h" 30 | #else 31 | 32 | // watchdog use timer 2 33 | //STATIC_ASSERT((WATCHDOG_INIT_TIMEOUT * CLOCK_SYS_CLOCK_1MS >> WATCHDOG_TIMEOUT_COEFF) > 0); 34 | static inline void wd_set_interval(int ms) // in ms 35 | { 36 | SET_FLD_V(reg_tmr_ctrl, FLD_TMR_WD_CAPT, (ms * CLOCK_SYS_CLOCK_1MS >> WATCHDOG_TIMEOUT_COEFF), FLD_TMR2_MODE, 0); 37 | reg_tmr2_tick = 0; 38 | } 39 | 40 | static inline void wd_start(void){ 41 | #if(MODULE_WATCHDOG_ENABLE) // if watchdog not set, start wd would cause problem 42 | SET_FLD(reg_tmr_ctrl, FLD_TMR_WD_EN); 43 | #endif 44 | } 45 | 46 | static inline void wd_stop(void){ 47 | #if(MODULE_WATCHDOG_ENABLE) 48 | CLR_FLD(reg_tmr_ctrl, FLD_TMR_WD_EN); 49 | #endif 50 | } 51 | 52 | static inline void wd_clear(void){ 53 | reg_tmr_sta = FLD_TMR_STA_WD; 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/adc_8263.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file adc_8263.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef ADC_8263_H_ 24 | #define ADC_8263_H_ 25 | #include "../common/types.h" 26 | 27 | void adc_init (); 28 | u16 adc_get (); 29 | 30 | #endif /* ADC_8263_H_ */ 31 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/gpio_8266.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/gpio_8266.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/pwm_8263.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file pwm_8263.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef PWM_8263_H_ 24 | #define PWM_8263_H_ 25 | 26 | 27 | #endif /* PWM_8263_H_ */ 28 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/register_8263.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/register_8263.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/register_8266.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/register_8266.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/register_8267.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/proj/mcu_spec/register_8267.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj/tl_common.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file tl_common.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "mcu/config.h" 26 | #include "common/types.h" 27 | #include "common/bit.h" 28 | #include "common/tutility.h" 29 | #include "common/static_assert.h" 30 | #include "common/assert.h" 31 | #include "../vendor/common/user_config.h" 32 | #include "common/compatibility.h" 33 | #if(MCU_CORE_TYPE == MCU_CORE_8258) 34 | #include "drivers/8258/analog.h" 35 | #include "drivers/8258/compiler.h" 36 | #include "drivers/8258/register.h" 37 | #include "drivers/8258/gpio.h" 38 | #include "drivers/8258/pwm.h" 39 | #include "drivers/8258/dma.h" 40 | #include "drivers/8258/clock.h" 41 | #include "drivers/8258/random.h" 42 | #elif(MCU_CORE_TYPE == MCU_CORE_8278) 43 | #include "drivers/8278/analog.h" 44 | #include "drivers/8278/compiler.h" 45 | #include "drivers/8278/register.h" 46 | #include "drivers/8278/gpio.h" 47 | #include "drivers/8278/pwm.h" 48 | #include "drivers/8278/dma.h" 49 | #include "drivers/8278/clock.h" 50 | #include "drivers/8278/random.h" 51 | #else 52 | #include "mcu/analog.h" 53 | #include "mcu/compiler.h" 54 | #include "mcu/register.h" 55 | #include "mcu/gpio.h" 56 | #include "mcu/pwm.h" 57 | #include "mcu/cpu.h" 58 | #include "mcu/dma.h" 59 | #include "mcu/clock.h" 60 | #include "mcu/clock_i.h" 61 | #include "mcu/random.h" 62 | #endif 63 | #include "mcu/irq_i.h" 64 | #include "common/breakpoint.h" 65 | #include "common/log.h" 66 | #include "drivers/8258/flash.h" 67 | //#include "../ble/ble_globals.h" 68 | 69 | #include "common/printf.h" 70 | #include "common/tstring.h" 71 | 72 | #define DEBUG_STOP() {reg_tmr_ctrl = 0; reg_gpio_pb_ie = 0xff; while(1);} // disable watchdog; DP/DM en 73 | #define DEBUG_SWS_EN() {reg_tmr_ctrl = 0; reg_gpio_pb_ie = 0xff;} // disable watchdog; DP/DM en 74 | 75 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/ble/hci/hci_event.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/ble/hci/hci_event.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/ble/ll/ll_encrypt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_encrypt.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | 24 | #ifndef BLE_LL_ENCRYPT_H_ 25 | #define BLE_LL_ENCRYPT_H_ 26 | 27 | 28 | 29 | 30 | 31 | typedef struct { 32 | u32 pkt; 33 | u8 dir; 34 | u8 iv[8]; 35 | } ble_cyrpt_nonce_t; 36 | 37 | 38 | typedef struct { 39 | u32 enc_pno; 40 | u32 dec_pno; 41 | u8 sk[16]; //session key 42 | ble_cyrpt_nonce_t nonce; 43 | u8 st; 44 | u8 enable; //1: slave enable; 2: master enable 45 | u8 mic_fail; 46 | } ble_crypt_para_t; 47 | 48 | #endif /* BLE_LL_ENCRYPT_H_ */ 49 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/ble/ll/ll_init.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_init.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_INIT_H_ 24 | #define LL_INIT_H_ 25 | 26 | 27 | 28 | typedef struct { 29 | u8 init_en; 30 | u8 conn_policy; 31 | u8 conn_advType; 32 | u8 conn_established; 33 | 34 | u32 create_conn_startTick; 35 | 36 | u8 conn_mac[6]; 37 | 38 | }st_ll_init_t; 39 | 40 | //st_ll_init_t blti; 41 | 42 | extern u32 blm_timeout_connectDevice; 43 | 44 | 45 | 46 | extern rf_packet_ll_init_t pkt_init; 47 | 48 | 49 | 50 | 51 | typedef int (*ll_module_init_callback_t)(u8 *, u32); 52 | 53 | 54 | 55 | 56 | 57 | static inline u32 rf_get_ble_access_code_16to32 (u16 code) 58 | { 59 | u32 r = 0; 60 | int i; 61 | for (i=0; i<4; i++) { 62 | r = r << 2; 63 | r |= code & BIT(i) ? 1 : 2; 64 | } 65 | 66 | for (i=4; i<8; i++) { //no more 24 transitions 67 | r = r << 4; 68 | r |= code & BIT(i) ? 0x0c : 0x03; 69 | } 70 | 71 | for (i=12; i<16; i++) { 72 | r = r << 2; 73 | r |= code & BIT(i) ? 1 : 2; 74 | } 75 | 76 | return r; 77 | } 78 | 79 | 80 | 81 | 82 | /******************************* User Interface ************************************/ 83 | void blc_ll_initInitiating_module(void); 84 | 85 | 86 | ble_sts_t blc_ll_createConnection (u16 scan_interval, u16 scan_window, u8 initiator_filter_policy, 87 | u8 adr_type, u8 *mac, u8 own_adr_type, 88 | u16 conn_min, u16 conn_max, u16 conn_latency, u16 timeout, 89 | u16 ce_min, u16 ce_max ); 90 | 91 | ble_sts_t blc_ll_createConnectionCancel (void); 92 | 93 | 94 | ble_sts_t blc_ll_setCreateConnectionTimeout (u32 timeout_ms); 95 | 96 | 97 | /************************* Stack Interface, user can not use!!! ***************************/ 98 | ble_sts_t blc_ll_setInitEnable (u8 en); 99 | 100 | 101 | #endif /* LL_INIT_H_ */ 102 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/ble/trace.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file trace.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef TRACE_H_ 24 | #define TRACE_H_ 25 | 26 | #define TR_T_irq 0 27 | #define TR_T_irq_rx 1 28 | #define TR_T_irq_tx 2 29 | #define TR_T_irq_sysTimer 3 30 | 31 | #define TR_T_irq_cmddone 4 32 | #define TR_T_irq_rxTmt 5 33 | #define TR_T_irq_rxFirstTmt 6 34 | #define TR_T_irq_fsmTmt 7 35 | 36 | #define TR_T_irq_rxCrcErr 8 37 | 38 | #define TR_T_ll_brx_start 9 39 | #define TR_T_ll_brx_end 10 40 | 41 | #define TR_T_ll_durationInit 11 42 | #define TR_T_ll_durationUpdate 12 43 | 44 | #define TR_T_ll_1stRx 13 45 | #define TR_T_ll_chn_map 14 46 | #define TR_T_ll_chn_timing 15 47 | #define TR_T_ll_scanRsp 16 48 | #define TR_T_ll_connReq 17 49 | 50 | #define TR_T_ll_sync 18 51 | #define TR_T_ll_adv 19 52 | 53 | #define TR_T_ll_stopRf 20 54 | 55 | 56 | #define TR_T_audioTask 24 57 | #define TR_T_audioData 25 58 | #define TR_T_adpcm 26 59 | #define TR_T_adpcm_enc_overflow 27 60 | 61 | 62 | 63 | #define TR_T_master_irq 30 64 | #define TR_T_master_rx 31 65 | #define TR_T_master_tx 32 66 | #define TR_T_master_sysTimer 33 67 | #define TR_T_master_connDone 34 68 | 69 | #define TR_T_master_adv_report 35 70 | 71 | //#define TR_T_master_createConn 40 72 | //#define TR_T_master_init 41 73 | //#define TR_T_master_connnect 42 74 | //#define TR_T_master_terminate 43 75 | //#define TR_T_master_btx 44 76 | //#define TR_T_master_scan 45 77 | 78 | //#define TR_T_master_update 50 79 | //#define TR_T_master_update_req 51 80 | 81 | 82 | 83 | 84 | #define TR_24_ll_chn 0 85 | #define TR_24_ll_duration 1 86 | 87 | 88 | 89 | #define TR_24_slot_idx 5 90 | #define TR_24_scan_chn 6 91 | #define TR_24_master_state 7 92 | 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/mesh_crypto/constants.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file constants.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef __TC_CONSTANTS_H__ 24 | #define __TC_CONSTANTS_H__ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | //#include 31 | 32 | #ifndef NULL 33 | #define NULL ((void *)0) 34 | #endif 35 | 36 | #define TC_CRYPTO_SUCCESS 1 37 | #define TC_CRYPTO_FAIL 0 38 | 39 | #define TC_ZERO_BYTE 0x00 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* __TC_CONSTANTS_H__ */ 46 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/mesh_crypto/mesh_md5.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file mesh_md5.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #ifndef __MESH_MD6_H 23 | #define __MESH_MD6_H 24 | 25 | #include "le_crypto.h" 26 | #include "mesh_crypto.h" 27 | #include "../../proj_lib/sig_mesh/app_mesh.h" 28 | 29 | 30 | typedef int S32; 31 | typedef unsigned int U32; 32 | typedef unsigned char U8; 33 | 34 | typedef U32 UINT4; 35 | typedef int INT4; 36 | 37 | typedef U8 *POINTER; 38 | typedef unsigned long uint32; 39 | 40 | /* MD5 context. */ 41 | struct MD5Context { 42 | uint32 buf[4]; 43 | uint32 bits[2]; 44 | unsigned char in[64]; 45 | }; 46 | 47 | typedef struct { 48 | u32 time_low; 49 | u16 time_mid; 50 | u16 time_hi_and_version; 51 | u8 clock_seq_hi_and_reserved; 52 | u8 clock_seq_low; 53 | u8 node[6]; 54 | } uuid_mesh_t; 55 | void uuid_create_md5_from_name(uuid_mesh_t *uuid, uuid_mesh_t nsid, void *name, 56 | int namelen); 57 | void uuid_create_by_mac(u8 *mac,u8 *uuid); 58 | void tl_md5(unsigned char *in, int len, unsigned char *out); 59 | #endif 60 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/pm.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file pm.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | #if (!WIN32) 25 | #include "proj/mcu/config.h" 26 | #endif 27 | #if(__TL_LIB_8266__ || MCU_CORE_TYPE == MCU_CORE_8266) 28 | #include "pm_8266.h" 29 | #elif(__TL_LIB_8267__ || MCU_CORE_TYPE == MCU_CORE_8267 || \ 30 | __TL_LIB_8261__ || MCU_CORE_TYPE == MCU_CORE_8261 || \ 31 | __TL_LIB_8269__ || MCU_CORE_TYPE == MCU_CORE_8269 ) 32 | 33 | #include "pm_8267.h" 34 | #elif(__TL_LIB_8366__ || MCU_CORE_TYPE == MCU_CORE_8366) 35 | #include "pm_8366.h" 36 | #elif(__TL_LIB_8258__ || MCU_CORE_TYPE == MCU_CORE_8258) 37 | #include "drivers/8258/pm.h" 38 | #elif( MCU_CORE_TYPE == MCU_CORE_8278) 39 | #include "drivers/8278/pm.h" 40 | #elif(__TL_LIB_8263__ || MCU_CORE_TYPE == MCU_CORE_8263) 41 | #include "pm_8263.h" 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/proj_lib/rf_drv.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file rf_drv.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | #ifndef LINUX 25 | #include "../proj/mcu/config.h" 26 | #if(__TL_LIB_8266__ || MCU_CORE_TYPE == MCU_CORE_8266) 27 | #include "rf_drv_8266.h" 28 | #elif(__TL_LIB_8267__ || MCU_CORE_TYPE == MCU_CORE_8267 || \ 29 | __TL_LIB_8261__ || MCU_CORE_TYPE == MCU_CORE_8261 || \ 30 | __TL_LIB_8269__ || MCU_CORE_TYPE == MCU_CORE_8269 ) 31 | #include "rf_drv_8267.h" 32 | #elif(__TL_LIB_8258__ || MCU_CORE_TYPE == MCU_CORE_8258 ) 33 | #include "drivers/8258/rf_drv.h" 34 | #elif(MCU_CORE_TYPE == MCU_CORE_8278 ) 35 | #include "drivers/8278/rf_drv.h" 36 | #elif(__TL_LIB_8263__ || MCU_CORE_TYPE == MCU_CORE_8263) 37 | #include "rf_drv_8263.h" 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/attr/gatt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file gatt.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef GATT_H_ 24 | #define GATT_H_ 25 | 26 | 27 | 28 | 29 | /************************************ User Interface *****************************************/ 30 | 31 | ble_sts_t blc_gatt_pushHandleValueNotify (u16 connHandle, u16 attHandle, u8 *p, int len); 32 | 33 | ble_sts_t blc_gatt_pushHandleValueIndicate(u16 connHandle, u16 attHandle, u8 *p, int len); 34 | 35 | 36 | ble_sts_t blc_gatt_pushWriteComand (u16 connHandle, u16 attHandle, u8 *p, int len); 37 | 38 | ble_sts_t blc_gatt_pushWriteRequest (u16 connHandle, u16 attHandle, u8 *p, int len); 39 | 40 | 41 | 42 | 43 | #if 0 //not available now 44 | 45 | ble_sts_t blc_gatt_pushFindInformationRequest(u8 *dat, u16 start_attHandle, u16 end_attHandle); 46 | 47 | ble_sts_t blc_gatt_pushFindByTypeValueRequest (u8 *dat, u16 start_attHandle, u16 end_attHandle, u8 *uuid, u8* attr_value, int len); 48 | 49 | ble_sts_t blc_gatt_pushReadByTypeRequest (u8 *dat, u16 start_attHandle, u16 end_attHandle, u8 *uuid, int uuid_len); 50 | 51 | ble_sts_t blc_gatt_pushReadRequest (u8 *dat, u16 attHandle); 52 | 53 | ble_sts_t blc_gatt_pushReadBlobRequest (u8 *dat, u16 attHandle, u16 offset); 54 | 55 | ble_sts_t blc_gatt_pushReadByGroupTypeRequest (u8 *dat, u16 start_attHandle, u16 end_attHandle, u8 *uuid, int uuid_len); 56 | 57 | 58 | #endif 59 | 60 | 61 | 62 | 63 | 64 | 65 | /****************************** Stack Interface, user can not use!!! ***************************/ 66 | u8 blc_gatt_requestServiceAccess(u16 connHandle, int gatt_perm); 67 | 68 | 69 | 70 | 71 | 72 | 73 | #endif /* GATT_H_ */ 74 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/ble.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ble.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef BLE_H_ 24 | #define BLE_H_ 25 | 26 | 27 | #include "proj_lib/ble/blt_config.h" 28 | #include "ble_common.h" 29 | 30 | 31 | #include "l2cap/l2cap.h" 32 | //#include "phy/phy.h" 33 | //#include "phy/phy_test.h" 34 | 35 | 36 | #include "proj_lib/ble/att.h" 37 | #include "attr/gatt.h" 38 | #include "proj_lib/ble/uuid.h" 39 | 40 | 41 | #include "smp/smp.h" 42 | #include "smp/smp_const.h" 43 | #include "smp/smp_central.h" 44 | #include "smp/smp_peripheral.h" 45 | #include "smp/smp_storage.h" 46 | 47 | #include "gap/gap.h" 48 | #include "gap/gap_event.h" 49 | 50 | //#include "crypt/aes_ccm.h" 51 | //#include "crypt/le_crypto.h" 52 | //#include "crypt/aes/aes_att.h" 53 | 54 | //#include "hci/hci.h" 55 | #include "hci/hci_const.h" 56 | #include "hci/hci_event.h" 57 | //#include "hci/usb_desc.h" 58 | 59 | #include "proj_lib/ble/service/ble_ll_ota.h" 60 | #include "service/device_information.h" 61 | //#include "service/hids.h" 62 | 63 | #include "ll/ll.h" 64 | #include "ll/ll_adv.h" 65 | #include "ll/ll_encrypt.h" 66 | #include "ll/ll_init.h" 67 | #include "ll/ll_pm.h" 68 | #include "ll/ll_scan.h" 69 | #include "ll/ll_whitelist.h" 70 | #include "ll/ll_conn/ll_conn.h" 71 | #include "ll/ll_conn/ll_slave.h" 72 | #include "ll/ll_conn/ll_master.h" 73 | #include "ll/ll_conn/ll_conn_phy.h" 74 | #include "ll/ll_conn/ll_conn_csa.h" 75 | 76 | #include "ll/ll_ext.h" 77 | //#include "ll/ll_ext_adv.h" 78 | #include "ll/ll_ext_scan.h" 79 | 80 | 81 | 82 | #include "llms/llms.h" 83 | #include "llms/llms_slot.h" 84 | #include "llms/llms_adv.h" 85 | #include "llms/llms_scan.h" 86 | #include "llms/llms_init.h" 87 | #include "llms/llms_slave.h" 88 | #include "llms/llms_master.h" 89 | 90 | #include "bqb/bqb_ll.h" 91 | 92 | #endif /* BLE_H_ */ 93 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/ble_controller.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ble_controller.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date Sep. 18, 2018 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef BLE_CONTROLLER_H_ 24 | #define BLE_CONTROLLER_H_ 25 | 26 | 27 | #include "proj_lib/ble/blt_config.h" 28 | #include "ble_common.h" 29 | 30 | 31 | #include "phy/phy.h" 32 | #include "phy/phy_test.h" 33 | 34 | 35 | 36 | #include "hci/hci.h" 37 | #include "hci/hci_const.h" 38 | #include "hci/hci_event.h" 39 | #include "hci/usb_desc.h" 40 | 41 | 42 | #include "ll/ll.h" 43 | #include "ll/ll_adv.h" 44 | #include "ll/ll_encrypt.h" 45 | #include "ll/ll_init.h" 46 | #include "ll/ll_pm.h" 47 | #include "ll/ll_scan.h" 48 | #include "ll/ll_whitelist.h" 49 | #include "ll/ll_conn/ll_conn.h" 50 | #include "ll/ll_conn/ll_slave.h" 51 | #include "ll/ll_conn/ll_master.h" 52 | #include "ll/ll_conn/ll_conn_phy.h" 53 | #include "ll/ll_conn/ll_conn_csa.h" 54 | 55 | #include "ll/ll_ext.h" 56 | #include "ll/ll_ext_adv.h" 57 | #include "ll/ll_ext_scan.h" 58 | 59 | 60 | 61 | #include "llms/llms.h" 62 | #include "llms/llms_slot.h" 63 | #include "llms/llms_adv.h" 64 | #include "llms/llms_scan.h" 65 | #include "llms/llms_init.h" 66 | #include "llms/llms_slave.h" 67 | #include "llms/llms_master.h" 68 | 69 | 70 | 71 | #include "bqb/bqb_ll.h" 72 | 73 | #endif /* BLE_H_ */ 74 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/ll/ll.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/ll/ll.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/ll/ll_conn/ll_conn_csa.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_conn_csa.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date July. 4, 2019 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_CONN_CSA_H_ 24 | #define LL_CONN_CSA_H_ 25 | 26 | 27 | 28 | /******************************* Macro & Enumeration variables for Stack, user can not use!!!! ********************************/ 29 | 30 | //See the Core_v5.0(Vol 6/Part B/4.5.8, "Data Channel Index Selection") for more information. 31 | typedef enum { 32 | CHANNAL_SELECTION_ALGORITHM_1 = 0x00, 33 | CHANNAL_SELECTION_ALGORITHM_2 = 0x01, 34 | } channel_algorithm_t; 35 | 36 | 37 | 38 | typedef u8 (*ll_chn_index_calc_callback_t)(u8*, u16, u16); 39 | extern ll_chn_index_calc_callback_t ll_chn_index_calc_cb; 40 | 41 | 42 | 43 | 44 | 45 | 46 | /******************************** Macro & Enumeration variables for User *****************************************************/ 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | /******************************** User Interface ****************************************************************************/ 61 | void blc_ll_initChannelSelectionAlgorithm_2_feature(void); 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | /******************************* Stack Interface, user can not use!!! *******************************************************/ 78 | u8 blc_calc_remapping_table(u8 chm[5]); 79 | 80 | u8 blc_ll_channel_index_calc_csa2(u8 chm[5], u16 event_cntr, u16 channel_id); 81 | 82 | 83 | 84 | 85 | #endif /* LL_CONN_CSA_H_ */ 86 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/ll/ll_conn/ll_conn_phy.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_conn_phy.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date July. 4, 2019 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_CONN_PHY_H_ 24 | #define LL_CONN_PHY_H_ 25 | 26 | 27 | //#include "stack/ble/phy/phy.h" 28 | 29 | 30 | 31 | /******************************* Macro & Enumeration variables for Stack, user can not use!!!! ********************************/ 32 | #if (LL_FEATURE_ENABLE_LE_2M_PHY | LL_FEATURE_ENABLE_LE_CODED_PHY) 33 | 34 | ll_conn_phy_t* blt_ll_get_conn_phy_ptr(u16 connHandle); 35 | extern _attribute_aligned_(4) ll_conn_phy_t blt_conn_phy; 36 | 37 | 38 | typedef int (*ll_conn_phy_update_callback_t)(void); 39 | typedef int (*ll_conn_phy_switch_callback_t)(void); 40 | 41 | extern ll_conn_phy_update_callback_t ll_conn_phy_update_cb; 42 | extern ll_conn_phy_switch_callback_t ll_conn_phy_swicth_cb; 43 | 44 | #endif 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | /******************************** Macro & Enumeration variables for User *****************************************************/ 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | /******************************** User Interface ****************************************************************************/ 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | /******************************* Stack Interface, user can not use!!! *******************************************************/ 87 | //2M/Coded PHY 88 | void blt_ll_sendPhyReq(void); 89 | int blt_ll_updateConnPhy(void); 90 | int blt_ll_switchConnPhy(void); 91 | 92 | 93 | 94 | 95 | #endif /* LL_CONN_CSA_H_ */ 96 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/ll/ll_encrypt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_encrypt.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | /* 23 | * ble_ll_encrypt.h 24 | * 25 | * Created on: 2016-9-22 26 | * Author: Telink 27 | */ 28 | 29 | #ifndef BLE_LL_ENCRYPT_H_ 30 | #define BLE_LL_ENCRYPT_H_ 31 | 32 | 33 | 34 | 35 | 36 | typedef struct { 37 | u32 pkt; 38 | u8 dir; 39 | u8 iv[8]; 40 | } ble_cyrpt_nonce_t; 41 | 42 | 43 | typedef struct { 44 | u32 enc_pno; 45 | u32 dec_pno; 46 | u8 sk[16]; //session key 47 | ble_cyrpt_nonce_t nonce; 48 | u8 st; 49 | u8 enable; //1: slave enable; 2: master enable 50 | u8 mic_fail; 51 | } ble_crypt_para_t; 52 | 53 | #endif /* BLE_LL_ENCRYPT_H_ */ 54 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/ll/ll_ext_scan.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_ext_scan.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Feb. 1, 2018 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_SCAN_EXT_H_ 24 | #define LL_SCAN_EXT_H_ 25 | 26 | #include 27 | #include "proj_lib/ble/blt_config.h" 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include "stack/ble/ll/ll_conn/ll_slave.h" 38 | #include "stack/ble/ll/ll_conn/ll_master.h" 39 | 40 | 41 | #include "proj/tl_common.h" 42 | #include "drivers.h" 43 | 44 | 45 | /******************************************** User Interface ********************************************************************/ 46 | ble_sts_t blc_ll_setExtScanParam_1_phy (own_addr_type_t ownAddrType, scan_fp_type_t scanFilterPolicy, u8 scan_phys, 47 | scan_type_t scanType, u16 scan_interval, u16 scan_window); 48 | 49 | ble_sts_t blc_hci_le_setExtScanEnable (scan_en_t extScan_en, dupFilter_en_t filter_duplicate, u16 duration, u16 period); 50 | 51 | 52 | 53 | /****************************************** Stack Interface, user can not use!!! *************************************************/ 54 | 55 | ble_sts_t blc_hci_le_setExtScanParam (own_addr_type_t ownAddrType, scan_fp_type_t scanFilterPolicy, u8 scan_phys, u8 *pData); 56 | 57 | 58 | #endif /* LL_SCAN_EXT_H_ */ 59 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/llms/llms_adv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_adv.h 3 | * 4 | * Created on: 2019-5-25 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_ADV_H_ 9 | #define LLMS_ADV_H_ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | /************************************ User Interface ******************************************************/ 24 | void blc_llms_initAdvertising_module(void);; 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | /*********************************** Stack Interface, user can not use!!! **********************************/ 33 | int blt_llms_send_adv(void); 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | #endif /* LLMS_ADV_H_ */ 44 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/llms/llms_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_init.h 3 | * 4 | * Created on: 2019-5-25 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_INIT_H_ 9 | #define LLMS_INIT_H_ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | extern int blms_create_connection; 19 | extern u32 blms_timeout_connectDevice; 20 | extern u32 blms_tick_connectDevice; 21 | 22 | 23 | 24 | /************************************ User Interface ******************************************************/ 25 | 26 | 27 | 28 | 29 | /*********************************** Stack Interface, user can not use!!! **********************************/ 30 | int blt_llms_procInitPkt(u8 *raw_pkt); 31 | 32 | 33 | 34 | 35 | #endif /* LLMS_INIT_H_ */ 36 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/llms/llms_master.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_master.h 3 | * 4 | * Created on: 2019-5-24 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_MASTER_H_ 9 | #define LLMS_MASTER_H_ 10 | 11 | 12 | 13 | /*************************************************************************** 14 | * 17 19 23 29 31 37 39 41 15 | * 21.25 23.75 28.75 36.25 38.75 46.25 48.75 51.25 16 | * X X 17 | * V V V 18 | * 19 | * 23 29 31 37 41 20 | **************************************************************************/ 21 | #define MASTER_CONN_INTER_23 23 22 | #define MASTER_CONN_INTER_29 29 23 | #define MASTER_CONN_INTER_31 31 24 | #define MASTER_CONN_INTER_37 37 25 | #define MASTER_CONN_INTER_41 41 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | typedef struct { 34 | u8 conn_policy; 35 | u8 conn_advType; 36 | u8 conn_num; 37 | u8 cur_connInterval; 38 | 39 | 40 | u8 conn_mac[6]; 41 | 42 | } st_llm_conn_t; 43 | 44 | extern st_llm_conn_t bltcm; 45 | 46 | 47 | /************************************ User Interface ******************************************************/ 48 | 49 | 50 | 51 | 52 | /*********************************** Stack Interface, user can not use!!! **********************************/ 53 | int blms_m_connect (rf_packet_connect_t * pInit); 54 | int blms_btx_start (void); 55 | int blms_btx_post (void); 56 | 57 | 58 | 59 | #endif /* LLMS_MASTER_H_ */ 60 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/llms/llms_scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_scan.h 3 | * 4 | * Created on: 2019-5-25 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_SCAN_H_ 9 | #define LLMS_SCAN_H_ 10 | 11 | 12 | 13 | /************************************ User Interface ******************************************************/ 14 | void blc_llms_initScanning_module(void); 15 | 16 | 17 | 18 | /*********************************** Stack Interface, user can not use!!! **********************************/ 19 | 20 | void blt_llms_switchScanChannel (int set_chn); 21 | int blt_llms_procScanPkt(u8 *raw_pkt, u8 *new_pkt, u32 tick_now); 22 | int blt_llms_procScanData(u8 *raw_pkt); 23 | 24 | #endif /* LLMS_SCAN_H_ */ 25 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/llms/llms_slave.h: -------------------------------------------------------------------------------- 1 | /* 2 | * llms_slave.h 3 | * 4 | * Created on: 2019-5-24 5 | * Author: Administrator 6 | */ 7 | 8 | #ifndef LLMS_SLAVE_H_ 9 | #define LLMS_SLAVE_H_ 10 | 11 | 12 | 13 | #define SLAVE_SYNC_CONN_CREATE BIT(0) 14 | #define SLAVE_SYNC_CONN_UPDATE BIT(1) 15 | #define SLAVE_SYNC_HIGH_DUTY BIT(7) 16 | 17 | 18 | #define SLAVE_SYNC_HIGHDUTY_SUPPORT_EN 0 19 | 20 | 21 | #define BRX_EARLY_SET_SYNC 300 22 | #define BRX_EARLY_SET_COMMON 200 23 | 24 | 25 | 26 | typedef struct { 27 | u8 slaveSync; // conn create or conn_param_update 28 | u8 conn_rcvd_ack_pkt; 29 | u8 rsvd1; 30 | u8 rsvd2; 31 | 32 | 33 | u32 connExpectTime; 34 | u32 conn_start_time; 35 | u32 conn_duration; 36 | 37 | u32 tick_1st_rx; 38 | 39 | } st_llms_s_conn_t; 40 | 41 | extern st_llms_s_conn_t bltcs; 42 | 43 | 44 | 45 | /************************************ User Interface ******************************************************/ 46 | 47 | 48 | 49 | 50 | /*********************************** Stack Interface, user can not use!!! **********************************/ 51 | int blms_s_connect (rf_packet_connect_t * pInit); 52 | int blms_brx_start(void); 53 | int blms_brx_post(void); 54 | 55 | 56 | 57 | 58 | #endif /* LLMS_SLAVE_H_ */ 59 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/llms/trace.h: -------------------------------------------------------------------------------- 1 | #ifndef TRACE_H_ 2 | #define TRACE_H_ 3 | 4 | #define TR_T_irq 1 5 | #define TR_T_irq_rx 2 6 | #define TR_T_irq_tx 3 7 | #define TR_T_irq_sysTimer 4 8 | #define TR_T_irq_adv 5 9 | 10 | 11 | #define TR_T_irq_cmddone 6 12 | #define TR_T_irq_rxTmt 7 13 | #define TR_T_irq_rxFirstTmt 8 14 | #define TR_T_irq_fsmTmt 9 15 | 16 | 17 | 18 | #define TR_T_ll_brx_start 10 19 | #define TR_T_ll_brx_post 11 20 | 21 | #define TR_T_ll_btx_start 12 22 | #define TR_T_ll_btx_post 13 23 | #define TR_T_ll_1stRx 14 24 | 25 | #define TR_T_ll_terminate 15 26 | 27 | #define TR_T_rx_crc 18 28 | #define TR_T_rx_conn 20 29 | 30 | 31 | #define TR_T_slot_update 20 32 | #define TR_T_slot_runout 22 33 | #define TR_T_slot_rebuild 23 34 | #define TR_T_slot_locate 24 35 | #define TR_T_slot_task 25 36 | 37 | #define TR_T_slot_jump 26 38 | 39 | #define TR_T_slave_sync 30 40 | #define TR_T_slave_sync_done 31 41 | 42 | 43 | #define TR_24_ll_chn 0 44 | #define TR_24_ll_duration 1 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/smpc/smp_ms.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/smpc/smp_ms.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble/trace.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file trace.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef TRACE_H_ 24 | #define TRACE_H_ 25 | 26 | #define TR_T_irq 0 27 | #define TR_T_irq_rx 1 28 | #define TR_T_irq_tx 2 29 | #define TR_T_irq_sysTimer 3 30 | 31 | #define TR_T_irq_cmddone 4 32 | #define TR_T_irq_rxTmt 5 33 | #define TR_T_irq_rxFirstTmt 6 34 | #define TR_T_irq_fsmTmt 7 35 | 36 | #define TR_T_irq_rxCrcErr 8 37 | 38 | #define TR_T_ll_brx_start 9 39 | #define TR_T_ll_brx_end 10 40 | 41 | #define TR_T_ll_durationInit 11 42 | #define TR_T_ll_durationUpdate 12 43 | 44 | #define TR_T_ll_1stRx 13 45 | #define TR_T_ll_chn_map 14 46 | #define TR_T_ll_chn_timing 15 47 | #define TR_T_ll_scanRsp 16 48 | #define TR_T_ll_connReq 17 49 | 50 | #define TR_T_ll_sync 18 51 | #define TR_T_ll_adv 19 52 | 53 | #define TR_T_ll_stopRf 20 54 | 55 | 56 | #define TR_T_audioTask 24 57 | #define TR_T_audioData 25 58 | #define TR_T_adpcm 26 59 | #define TR_T_adpcm_enc_overflow 27 60 | 61 | 62 | 63 | #define TR_T_master_irq 30 64 | #define TR_T_master_rx 31 65 | #define TR_T_master_tx 32 66 | #define TR_T_master_sysTimer 33 67 | #define TR_T_master_connDone 34 68 | 69 | #define TR_T_master_adv_report 35 70 | 71 | #define TR_T_master_createConn 40 72 | #define TR_T_master_init 41 73 | #define TR_T_master_connnect 42 74 | #define TR_T_master_terminate 43 75 | #define TR_T_master_btx 44 76 | #define TR_T_master_scan 45 77 | 78 | #define TR_T_master_update 50 79 | #define TR_T_master_update_req 51 80 | 81 | 82 | 83 | 84 | #define TR_24_ll_chn 0 85 | #define TR_24_ll_duration 1 86 | 87 | 88 | 89 | #define TR_24_slot_idx 5 90 | #define TR_24_scan_chn 6 91 | #define TR_24_master_state 7 92 | 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble_8278/attr/gatt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file gatt.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef GATT_H_ 24 | #define GATT_H_ 25 | 26 | 27 | 28 | 29 | /************************************ User Interface *****************************************/ 30 | 31 | ble_sts_t blc_gatt_pushHandleValueNotify (u16 connHandle, u16 attHandle, u8 *p, int len); 32 | 33 | ble_sts_t blc_gatt_pushHandleValueIndicate(u16 connHandle, u16 attHandle, u8 *p, int len); 34 | 35 | 36 | ble_sts_t blc_gatt_pushWriteComand (u16 connHandle, u16 attHandle, u8 *p, int len); 37 | 38 | ble_sts_t blc_gatt_pushWriteRequest (u16 connHandle, u16 attHandle, u8 *p, int len); 39 | 40 | 41 | 42 | 43 | #if 0 //not available now 44 | 45 | ble_sts_t blc_gatt_pushFindInformationRequest(u8 *dat, u16 start_attHandle, u16 end_attHandle); 46 | 47 | ble_sts_t blc_gatt_pushFindByTypeValueRequest (u8 *dat, u16 start_attHandle, u16 end_attHandle, u8 *uuid, u8* attr_value, int len); 48 | 49 | ble_sts_t blc_gatt_pushReadByTypeRequest (u8 *dat, u16 start_attHandle, u16 end_attHandle, u8 *uuid, int uuid_len); 50 | 51 | ble_sts_t blc_gatt_pushReadRequest (u8 *dat, u16 attHandle); 52 | 53 | ble_sts_t blc_gatt_pushReadBlobRequest (u8 *dat, u16 attHandle, u16 offset); 54 | 55 | ble_sts_t blc_gatt_pushReadByGroupTypeRequest (u8 *dat, u16 start_attHandle, u16 end_attHandle, u8 *uuid, int uuid_len); 56 | 57 | 58 | #endif 59 | 60 | 61 | 62 | 63 | 64 | 65 | /****************************** Stack Interface, user can not use!!! ***************************/ 66 | u8 blc_gatt_requestServiceAccess(u16 connHandle, int gatt_perm); 67 | 68 | 69 | 70 | 71 | 72 | 73 | #endif /* GATT_H_ */ 74 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble_8278/ble_controller.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ble_controller.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date Sep. 18, 2018 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef BLE_CONTROLLER_H_ 24 | #define BLE_CONTROLLER_H_ 25 | 26 | 27 | #include "proj_lib/ble/blt_config.h" 28 | #include "ble_common.h" 29 | 30 | 31 | #include "phy/phy.h" 32 | #include "phy/phy_test.h" 33 | 34 | 35 | 36 | #include "hci/hci.h" 37 | #include "hci/hci_const.h" 38 | #include "hci/hci_event.h" 39 | #include "hci/usb_desc.h" 40 | 41 | 42 | #include "ll/ll.h" 43 | #include "ll/ll_adv.h" 44 | #include "ll/ll_encrypt.h" 45 | #include "ll/ll_init.h" 46 | #include "ll/ll_pm.h" 47 | #include "ll/ll_scan.h" 48 | #include "ll/ll_whitelist.h" 49 | #include "ll/ll_conn/ll_conn.h" 50 | #include "ll/ll_conn/ll_slave.h" 51 | #include "ll/ll_conn/ll_master.h" 52 | #include "ll/ll_conn/ll_conn_phy.h" 53 | #include "ll/ll_conn/ll_conn_csa.h" 54 | 55 | #include "ll/ll_ext.h" 56 | #include "ll/ll_ext_adv.h" 57 | #include "ll/ll_ext_scan.h" 58 | 59 | 60 | 61 | #include "llms/llms.h" 62 | #include "llms/llms_slot.h" 63 | #include "llms/llms_adv.h" 64 | #include "llms/llms_scan.h" 65 | #include "llms/llms_init.h" 66 | #include "llms/llms_slave.h" 67 | #include "llms/llms_master.h" 68 | #include "llms/llms_conn.h" 69 | 70 | 71 | #include "bqb/bqb_ll.h" 72 | 73 | #endif /* BLE_H_ */ 74 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble_8278/ll/ll.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble_8278/ll/ll.h -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble_8278/ll/ll_conn/ll_conn_csa.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_conn_csa.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date July. 4, 2019 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_CONN_CSA_H_ 24 | #define LL_CONN_CSA_H_ 25 | 26 | 27 | 28 | /******************************* Macro & Enumeration variables for Stack, user can not use!!!! ********************************/ 29 | 30 | //See the Core_v5.0(Vol 6/Part B/4.5.8, "Data Channel Index Selection") for more information. 31 | typedef enum { 32 | CHANNAL_SELECTION_ALGORITHM_1 = 0x00, 33 | CHANNAL_SELECTION_ALGORITHM_2 = 0x01, 34 | } channel_algorithm_t; 35 | 36 | 37 | 38 | typedef u8 (*ll_chn_index_calc_callback_t)(u8*, u16, u16); 39 | extern ll_chn_index_calc_callback_t ll_chn_index_calc_cb; 40 | 41 | 42 | 43 | 44 | 45 | 46 | /******************************** Macro & Enumeration variables for User *****************************************************/ 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | /******************************** User Interface ****************************************************************************/ 61 | void blc_ll_initChannelSelectionAlgorithm_2_feature(void); 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | /******************************* Stack Interface, user can not use!!! *******************************************************/ 78 | u8 blc_calc_remapping_table(u8 chm[5]); 79 | 80 | u8 blc_ll_channel_index_calc_csa2(u8 chm[5], u16 event_cntr, u16 channel_id); 81 | 82 | 83 | 84 | 85 | #endif /* LL_CONN_CSA_H_ */ 86 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble_8278/ll/ll_conn/ll_conn_phy.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_conn_phy.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author BLE Group 7 | * @date July. 4, 2019 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef LL_CONN_PHY_H_ 24 | #define LL_CONN_PHY_H_ 25 | 26 | 27 | //#include "stack/ble/phy/phy.h" 28 | 29 | 30 | 31 | /******************************* Macro & Enumeration variables for Stack, user can not use!!!! ********************************/ 32 | #if (LL_FEATURE_ENABLE_LE_2M_PHY | LL_FEATURE_ENABLE_LE_CODED_PHY) 33 | 34 | ll_conn_phy_t* blt_ll_get_conn_phy_ptr(u16 connHandle); 35 | extern _attribute_aligned_(4) ll_conn_phy_t blt_conn_phy; 36 | 37 | 38 | typedef int (*ll_conn_phy_update_callback_t)(void); 39 | typedef int (*ll_conn_phy_switch_callback_t)(void); 40 | 41 | extern ll_conn_phy_update_callback_t ll_conn_phy_update_cb; 42 | extern ll_conn_phy_switch_callback_t ll_conn_phy_swicth_cb; 43 | 44 | #endif 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | /******************************** Macro & Enumeration variables for User *****************************************************/ 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | /******************************** User Interface ****************************************************************************/ 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | /******************************* Stack Interface, user can not use!!! *******************************************************/ 87 | //2M/Coded PHY 88 | void blt_ll_sendPhyReq(void); 89 | int blt_ll_updateConnPhy(void); 90 | int blt_ll_switchConnPhy(void); 91 | 92 | 93 | 94 | 95 | #endif /* LL_CONN_CSA_H_ */ 96 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble_8278/ll/ll_encrypt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ll_encrypt.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | /* 23 | * ble_ll_encrypt.h 24 | * 25 | * Created on: 2016-9-22 26 | * Author: Telink 27 | */ 28 | 29 | #ifndef BLE_LL_ENCRYPT_H_ 30 | #define BLE_LL_ENCRYPT_H_ 31 | 32 | 33 | 34 | 35 | 36 | typedef struct { 37 | u32 pkt; 38 | u8 dir; 39 | u8 iv[8]; 40 | } ble_cyrpt_nonce_t; 41 | 42 | 43 | typedef struct { 44 | u32 enc_pno; 45 | u32 dec_pno; 46 | u8 sk[16]; //session key 47 | ble_cyrpt_nonce_t nonce; 48 | u8 st; 49 | u8 enable; //1: slave enable; 2: master enable 50 | u8 mic_fail; 51 | } ble_crypt_para_t; 52 | 53 | #endif /* BLE_LL_ENCRYPT_H_ */ 54 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/stack/ble_8278/trace.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file trace.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author public@telink-semi.com; 7 | * @date Sep. 18, 2015 8 | * 9 | * @par Copyright (c) Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef TRACE_H_ 24 | #define TRACE_H_ 25 | 26 | #define TR_T_irq 0 27 | #define TR_T_irq_rx 1 28 | #define TR_T_irq_tx 2 29 | #define TR_T_irq_sysTimer 3 30 | 31 | #define TR_T_irq_cmddone 4 32 | #define TR_T_irq_rxTmt 5 33 | #define TR_T_irq_rxFirstTmt 6 34 | #define TR_T_irq_fsmTmt 7 35 | 36 | #define TR_T_irq_rxCrcErr 8 37 | 38 | #define TR_T_ll_brx_start 9 39 | #define TR_T_ll_brx_end 10 40 | 41 | #define TR_T_ll_durationInit 11 42 | #define TR_T_ll_durationUpdate 12 43 | 44 | #define TR_T_ll_1stRx 13 45 | #define TR_T_ll_chn_map 14 46 | #define TR_T_ll_chn_timing 15 47 | #define TR_T_ll_scanRsp 16 48 | #define TR_T_ll_connReq 17 49 | 50 | #define TR_T_ll_sync 18 51 | #define TR_T_ll_adv 19 52 | 53 | #define TR_T_ll_stopRf 20 54 | 55 | 56 | #define TR_T_audioTask 24 57 | #define TR_T_audioData 25 58 | #define TR_T_adpcm 26 59 | #define TR_T_adpcm_enc_overflow 27 60 | 61 | 62 | 63 | #define TR_T_master_irq 30 64 | #define TR_T_master_rx 31 65 | #define TR_T_master_tx 32 66 | #define TR_T_master_sysTimer 33 67 | #define TR_T_master_connDone 34 68 | 69 | #define TR_T_master_adv_report 35 70 | 71 | #define TR_T_master_createConn 40 72 | #define TR_T_master_init 41 73 | #define TR_T_master_connnect 42 74 | #define TR_T_master_terminate 43 75 | #define TR_T_master_btx 44 76 | #define TR_T_master_scan 45 77 | 78 | #define TR_T_master_update 50 79 | #define TR_T_master_update_req 51 80 | 81 | 82 | 83 | 84 | #define TR_24_ll_chn 0 85 | #define TR_24_ll_duration 1 86 | 87 | 88 | 89 | #define TR_24_slot_idx 5 90 | #define TR_24_scan_chn 6 91 | #define TR_24_master_state 7 92 | 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/tl_common.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file tl_common.h 3 | * 4 | * @brief This is the header file for TLSR8258 5 | * 6 | * @author author@telink-semi.com; 7 | * @date May 8, 2018 8 | * 9 | * @par Copyright (c) 2018, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee or the terms described here-in. This heading 16 | * MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | #include "proj/tl_common.h" 25 | 26 | #define SHOW_FUNC_IN(msg, arg...) printf("> %s(%d): " msg "\n", __FUNCTION__,__LINE__, ##arg) 27 | #define SHOW_FUNC_OUT(msg, arg...) printf("< %s(%d): " msg "\n\n", __FUNCTION__,__LINE__, ##arg) 28 | #define SHOW_DBG(msg, arg...) printf("%s:%s(%d): " msg "\n", __FILE__, __FUNCTION__,__LINE__, ##arg) 29 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/base/app.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file app.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj/tl_common.h" 26 | 27 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/att_handle_index.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file att_handle_index.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #ifndef _ATT_HANDLE_INDEX_ 23 | #define _ATT_HANDLE_INDEX_ 24 | 25 | //////////////////////////////////////////////////////////////////// 26 | // corrseponding to my_Attributes[] 27 | #if VIN_TEST_MODE 28 | #define MAX_ATT_FUNC 74 29 | #else 30 | #define MAX_ATT_FUNC (65+7+1) // 31 | #endif 32 | 33 | #define HID_HANDLE_CONSUME_CONTROL_IN (7+7) //14 34 | #define HID_HANDLE_KEYBOARD_REPORT (18+7) //25 35 | 36 | #define AUDIO_HANDLE_MIC (36+7) //43 mic_data 37 | 38 | //Battery 39 | #define HANDLE_BATTERY_VALUE (33+7) //0x28, 1bytes 40 | 41 | //Immediate Alert 42 | #define HANDLE_ALERT_LEVEL (46+7) //0x35 43 | 44 | //Device Information Service, STR for ASCII char 45 | #define HANDLE_SYS_ID (49+7) //0x38, 1byte 46 | #define HANDLE_MODEL_NO_STR (51+7) //0x3a 47 | #define HANDLE_SERIAL_NO_STR (53+7) //0x3c 48 | #define HANDLE_FW_VER_STR (55+7) //0x3e 49 | #define HANDLE_HW_VER_STR (57+7) //0x40 50 | #define HANDLE_SW_VER_STR (59+7) //0x42 51 | #define HANDLE_MANU_NAME_STR (61+7) //0x44 52 | #define HANDLE_CERT_DATA_STR (63+7) //0x46 IEEE 53 | #define HANDLE_PNP_ID (65+7) //0x48 54 | 55 | 56 | #define CONTROL_START 0xF0 57 | #define CONTROL_PAIR 0xF0 58 | #define CONTROL_UNPAIR 0xF1 59 | #define CONTROL_OTA 0xF8 60 | #define CONTROL_REBOOT 0xF9 61 | 62 | // cmd reg :0x8000 63 | // len :0x8002~0x8003 64 | // data :0x8008~0x800f 65 | 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/blt_led.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file blt_led.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #ifndef BLT_LED_H_ 24 | #define BLT_LED_H_ 25 | 26 | #include "../../proj/tl_common.h" 27 | 28 | 29 | //led management 30 | typedef struct{ 31 | unsigned short onTime_ms; 32 | unsigned short offTime_ms; 33 | 34 | unsigned char repeatCount; //0xff special for long on(offTime_ms=0)/long off(onTime_ms=0) 35 | unsigned char priority; //0x00 < 0x01 < 0x02 < 0x04 < 0x08 < 0x10 < 0x20 < 0x40 < 0x80 36 | } led_cfg_t; 37 | 38 | typedef struct { 39 | unsigned char isOn; 40 | unsigned char polar; 41 | unsigned char repeatCount; 42 | unsigned char priority; 43 | 44 | 45 | unsigned short onTime_ms; 46 | unsigned short offTime_ms; 47 | 48 | unsigned int gpio_led; 49 | unsigned int startTick; 50 | }device_led_t; 51 | 52 | extern device_led_t device_led; 53 | 54 | #define DEVICE_LED_BUSY (device_led.repeatCount) 55 | 56 | extern void led_proc(void); 57 | extern void device_led_init(u32 gpio,u8 polarity); 58 | int device_led_setup(led_cfg_t led_cfg); 59 | 60 | static inline void device_led_process(void) 61 | { 62 | if(DEVICE_LED_BUSY){ 63 | led_proc(); 64 | } 65 | } 66 | 67 | 68 | 69 | 70 | #endif /* BLT_LED_H_ */ 71 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/dual_mode_adapt.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file dual_mode_adapt.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj/tl_common.h" 26 | 27 | #define FW_RAMCODE_SIZE_MAX (0x4000) // no limit for bootloader. 28 | 29 | 30 | #define DUAL_MODE_FW_ADDR_SIGMESH (0x00000) 31 | #define DUAL_MODE_FW_ADDR_ZIGBEE (0x40000) 32 | 33 | enum{ 34 | RF_MODE_BLE = 0, 35 | RF_MODE_ZIGBEE, 36 | }; 37 | 38 | enum{ 39 | DUAL_MODE_SAVE_ENABLE = 0x5A, // dual mode state should be define both 73000 and 76080 40 | DUAL_MODE_SAVE_DISABLE = 0x00, 41 | // all other is disable exclude 0xff 42 | }; 43 | 44 | enum{ 45 | DUAL_MODE_NOT_SUPPORT = 0x00, 46 | DUAL_MODE_SUPPORT_ENABLE = 0x01, // must 0xff 47 | DUAL_MODE_SUPPORT_DISABLE = 0x02, 48 | }; 49 | 50 | enum{ 51 | DUAL_MODE_CALI_VAL_FLAG = 0x5A, 52 | }; 53 | 54 | extern u8 rf_mode; 55 | extern u8 dual_mode_state; 56 | int is_ble_found(); 57 | int is_zigbee_found(); 58 | u8 dual_mode_proc(); 59 | void dual_mode_en_init(); 60 | void dual_mode_select(); 61 | void dual_mode_disable(); 62 | void irq_zigbee_sdk_handler(void); 63 | 64 | // telink mesh 65 | void dual_mode_restore_TLK_4K(); 66 | int UI_resotre_TLK_4K_with_check(); 67 | 68 | 69 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/ev.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file ev.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj_lib/ble/ll/ll.h" 26 | #include "../../proj_lib/ble/blt_config.h" 27 | #include "../../proj_lib/sig_mesh/app_mesh.h" 28 | #include "../../proj_lib/ble/service/ble_ll_ota.h" 29 | #include "../../proj/common/utlist.h" 30 | #include "light.h" 31 | 32 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/fast_provision_model.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file lighting_model.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj/tl_common.h" 26 | #include "../../proj_lib/sig_mesh/app_mesh.h" 27 | 28 | extern my_fifo_t fast_prov_mac_fifo; 29 | 30 | int mesh_reset_network(u8 provision_enable, u16 recover_time_s); 31 | 32 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/generic_model.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file generic_model.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj/tl_common.h" 26 | #include "../../proj_lib/sig_mesh/app_mesh.h" 27 | 28 | /** @addtogroup Mesh_Common 29 | * @{ 30 | */ 31 | 32 | 33 | /** @addtogroup General_Model 34 | * @brief General Models Code. 35 | * @{ 36 | */ 37 | 38 | 39 | //----------------------------------- op code 40 | // op cmd 0xxxxxxx (SIG) 41 | 42 | // op cmd 10xxxxxx xxxxxxxx (SIG) 43 | 44 | //------------------vendor op end------------------- 45 | 46 | extern u16 size_page0; 47 | 48 | 49 | int g_onoff_set(mesh_cmd_g_onoff_set_t *p_set, int par_len, int force_last, int idx, u8 retransaction, st_pub_list_t *pub_list); 50 | 51 | 52 | /** 53 | * @} 54 | */ 55 | 56 | /** 57 | * @} 58 | */ 59 | 60 | 61 | #define mesh_cmd_sig_g_level_status (0) 62 | #define mesh_cmd_sig_def_trans_time_status (0) 63 | #define mesh_cmd_sig_g_on_powerup_status (0) 64 | #define mesh_cmd_sig_g_power_status (0) 65 | #define mesh_cmd_sig_g_power_last_status (0) 66 | #define mesh_cmd_sig_g_power_def_status (0) 67 | #define mesh_cmd_sig_g_power_range_status (0) 68 | #define mesh_cmd_sig_g_battery_status (0) 69 | #define mesh_cmd_sig_g_location_global_status (0) 70 | #define mesh_cmd_sig_g_location_local_status (0) 71 | // ----------- 72 | 73 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mesh_fn.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file mesh_fn.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj/tl_common.h" 26 | //#include "../../vendor/mesh/app.h" 27 | //#include "../../vendor/mesh_lpn/app.h" 28 | //#include "../../vendor/mesh_provision/app.h" 29 | //#include "../../vendor/mesh_switch/app.h" 30 | 31 | enum{ 32 | FS_DISCONNECT_TYPE_POLL_TIMEOUT = 1, 33 | FS_DISCONNECT_TYPE_CLEAR = 2, 34 | FS_DISCONNECT_TYPE_RX_REQUEST = 3, // receive request when being keeping friend ship. 35 | }; 36 | 37 | void mesh_feature_set_fn(); 38 | void fn_update_RecWin(u8 RecWin); 39 | u32 get_RecWin_connected(); 40 | void friend_ship_establish_ok_cb_fn(u8 lpn_idx); 41 | void friend_ship_disconnect_cb_fn(u8 lpn_idx, int type); 42 | u8 mesh_get_fn_cache_size_log_cnt(); 43 | void friend_cmd_send_offer(u8 lpn_idx); 44 | void friend_cmd_send_update(u8 lpn_idx, u8 md); 45 | void friend_cmd_send_clear(u16 adr_dst, u8 *par, u32 len); 46 | void friend_cmd_send_clear_conf(u16 adr_dst, u8 *par, u32 len); 47 | void friend_cmd_send_subsc_conf(u16 adr_dst, u8 transNo); 48 | int mesh_tx_cmd_layer_upper_ctl_FN(u8 op, u8 *par, u32 len_par, u16 adr_dst); 49 | void mesh_iv_update_start_poll_fn(u8 iv_update_by_sno, u8 beacon_iv_update_pkt_flag); 50 | u16 mesh_group_match_friend(u16 adr); 51 | 52 | 53 | extern u8 g_max_lpn_num; 54 | extern u8 use_mesh_adv_fifo_fn2lpn; 55 | 56 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mesh_test_cmd.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file mesh_test_cmd.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #include "../../proj/tl_common.h" 23 | 24 | #define SEC_MES_DEBUG_EN 0 25 | #define FRIEND_MSG_TEST_EN 0 26 | 27 | #define FRI_SAMPLE_EN 0 28 | #define SEG_DEBUG_LED(on) //do{ light_onoff_all(on);}while(0) 29 | 30 | 31 | void mesh_message6(); 32 | void friend_cmd_send_sample_message(u8 op); 33 | void friend_ship_sample_message_test(); 34 | void mesh_message_fri_msg_ctl_seg(); 35 | int mesh_tx_cmd_layer_upper_ctl_primary(u8 op, u8 *par, u32 len_par, u16 adr_dst); 36 | void test_cmd_wakeup_lpn(); 37 | void test_cmd_tdebug(); 38 | 39 | 40 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/common/crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef MIJIA_BLE_LIBS_COMMON_CRC32_H_ 2 | #define MIJIA_BLE_LIBS_COMMON_CRC32_H_ 3 | #include 4 | 5 | uint32_t soft_crc32(uint8_t const * p_data, uint32_t size, uint32_t init_crc); 6 | 7 | #endif /* MIJIA_BLE_LIBS_COMMON_CRC32_H_ */ 8 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/common/mible_beacon_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef MIBLE_BEACON_INTERNAL_H__ 2 | #define MIBLE_BEACON_INTERNAL_H__ 3 | 4 | #include "mible_type.h" 5 | #include "mible_port.h" 6 | 7 | typedef struct { 8 | uint8_t reserved0 :1; 9 | uint8_t reserved1 :1; 10 | uint8_t reserved2 :1; 11 | uint8_t is_encrypt :1; 12 | uint8_t mac_include :1; 13 | uint8_t cap_include :1; 14 | uint8_t obj_include :1; 15 | uint8_t mesh_include :1; 16 | 17 | uint8_t registered :1; 18 | uint8_t solicite :1; 19 | uint8_t auth_mode :2; 20 | uint8_t version :4; 21 | } mibeacon_frame_ctrl_t; 22 | 23 | typedef struct { 24 | uint16_t type; 25 | uint8_t len; 26 | uint8_t need_encrypt; 27 | uint8_t val[12]; 28 | } mibeacon_obj_t; 29 | 30 | typedef struct { 31 | uint8_t connectable :1; 32 | uint8_t centralable :1; 33 | uint8_t encryptable :1; 34 | uint8_t bondAbility :2; 35 | uint8_t IO_capability:1; 36 | uint8_t reserved :2; 37 | } mibeacon_capability_t; 38 | 39 | typedef struct { 40 | uint8_t in_digits :1; 41 | uint8_t RFU0 :1; 42 | uint8_t RFU1 :1; 43 | uint8_t RFU2 :1; 44 | uint8_t out_digits :1; 45 | uint8_t RFU3 :1; 46 | uint8_t RFU4 :1; 47 | uint8_t out_image :1; 48 | 49 | uint8_t reserved :8; 50 | } mibeacon_cap_sub_io_t; 51 | 52 | typedef struct { 53 | uint8_t pb_adv :1; 54 | uint8_t pb_gatt :1; 55 | uint8_t state :2; 56 | uint8_t version :4; 57 | 58 | uint8_t reserved :8; 59 | } mibeacon_mesh_t; 60 | 61 | typedef struct { 62 | mibeacon_frame_ctrl_t frame_ctrl; 63 | uint16_t pid; 64 | mible_addr_t *p_mac; 65 | mibeacon_capability_t *p_capability; 66 | mibeacon_cap_sub_io_t *p_cap_sub_IO; 67 | uint8_t *p_wifi_mac; 68 | mibeacon_obj_t *p_obj; 69 | uint8_t obj_num; 70 | mibeacon_mesh_t *p_mesh; 71 | } mibeacon_config_t; 72 | 73 | mible_status_t mibeacon_init(uint8_t key[16], bool newone); 74 | int get_mibeacon_solicited_bit(void); 75 | 76 | #endif //MIBLE_BEACON_INTERNAL_H__ 77 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/common/mible_crypto.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIBLE_CRYPTO_H__ 2 | #define __MIBLE_CRYPTO_H__ 3 | #include 4 | 5 | typedef struct { 6 | uint8_t dev_key[16]; 7 | uint8_t app_key[16]; 8 | uint32_t dev_iv; 9 | uint32_t app_iv; 10 | uint8_t reserve[24]; 11 | } session_ctx_t; 12 | 13 | int mi_session_init(session_ctx_t *p_ctx); 14 | int mi_session_uninit(void); 15 | /**@brief Function for encrypt the data. 16 | * 17 | * @details After Secure auth login, device and application will both generate the 18 | * same session key. This key will used to encrypt the data by AES128-CCM. The 19 | * output is concatenating LSB of counter in nonce, cipher text and the MIC. So 20 | * the length of output buffer MUST be 6 bytes larger than input buffer. 21 | * 22 | * @param[in] input plain text. 23 | * @param[in] len plain text bytes. 24 | * @param[out] output cipher text and 6-bytes extra info. 25 | */ 26 | int mi_session_encrypt(const uint8_t *input, uint8_t len, uint8_t *output); 27 | 28 | /**@brief Function for handling the Xiaomi Service's BLE events. 29 | * 30 | * @param[in] input cipher text and 6-bytes extra info. 31 | * @param[in] len num of byte. 32 | * @param[out] output plain text. 33 | */ 34 | int mi_session_decrypt(const uint8_t *input, uint8_t len, uint8_t *output); 35 | #endif /* __MIBLE_CRYPTO_H__ */ 36 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/common/mible_rxfer.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIBLE_RXFER_H__ 2 | #define __MIBLE_RXFER_H__ 3 | #include 4 | #include "third_party/pt/pt.h" 5 | #include "third_party/pt/pt_misc.h" 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define PASS_THROUGH 0x00 11 | #define DEV_CERT 0x01 12 | #define DEV_MANU_CERT 0x02 13 | #define ECC_PUBKEY 0x03 14 | #define DEV_SIGNATURE 0x04 15 | #define DEV_LOGIN_INFO 0x05 16 | #define DEV_SHARE_INFO 0x06 17 | #define SERVER_CERT 0x07 18 | #define SERVER_SIGN 0x08 19 | #define MESH_CONFIG 0x09 20 | #define APP_CONFIRMATION 0x0A 21 | #define APP_RANDOM 0x0B 22 | #define DEV_CONFIRMATION 0x0C 23 | #define DEV_RANDOM 0x0D 24 | #define BIND_KEY 0x0E 25 | 26 | 27 | typedef struct { 28 | uint16_t conn_handle; 29 | uint16_t srv_handle; 30 | uint16_t value_handle; 31 | uint16_t data_size; 32 | uint8_t *pdata; 33 | 34 | pstimer_t *p_timer; 35 | 36 | uint8_t state; 37 | uint8_t cmd_type; 38 | uint8_t cmd; 39 | uint8_t ack_type; 40 | uint8_t ack; 41 | 42 | uint16_t recv_sn; 43 | uint16_t max_sn; 44 | 45 | uint8_t last_rx_bytes; 46 | uint8_t lost_pkt_cnt; 47 | } rxfer_cb_t; 48 | 49 | int format_rx_cb(rxfer_cb_t *pxfer, void *p_rxd, uint16_t rxd_bytes); 50 | int format_tx_cb(rxfer_cb_t *pxfer, void *p_txd, uint16_t txd_bytes); 51 | int rxfer_init(rxfer_cb_t *pxfer, pstimer_t *p_timer); 52 | void rxfer_features_get(uint8_t *p_simul_retran, uint8_t *p_dmtu); 53 | void rxfer_process(rxfer_cb_t *pxfer, uint8_t *pdata, uint8_t len); 54 | 55 | PT_THREAD(rxfer_rx_thd(pt_t *pt, rxfer_cb_t *pxfer, uint8_t data_type, ...)); 56 | PT_THREAD(rxfer_tx_thd(pt_t *pt, rxfer_cb_t *pxfer, uint8_t data_type)); 57 | PT_THREAD(rxfer_mng_thd(pt_t *pt, rxfer_cb_t *pxfer, uint8_t cmd, ...)); 58 | 59 | #ifdef __cplusplus 60 | } 61 | #endif 62 | 63 | /** @} */ 64 | 65 | #endif /* __MIBLE_RXFER_H__ */ 66 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/common/queue.h: -------------------------------------------------------------------------------- 1 | #ifndef __QUEUE_H_ 2 | #define __QUEUE_H_ 3 | 4 | #include 5 | #include "mible_type.h" 6 | 7 | typedef struct { 8 | void * buf; 9 | uint8_t size; 10 | uint8_t offset; 11 | uint8_t rd_pos; 12 | uint8_t wr_pos; 13 | uint8_t cnt; 14 | } queue_t; 15 | 16 | mible_status_t queue_init(queue_t *q, void *buf, char size, char elem_size); 17 | mible_status_t enqueue(queue_t *q, void *in); 18 | mible_status_t dequeue(queue_t *q, void *out); 19 | void queue_flush(queue_t *q); 20 | 21 | #endif //__QUEUE_H_ 22 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/common/tlv.h: -------------------------------------------------------------------------------- 1 | #ifndef MIJIA_BLE_LIBS_COMMON_TLV_H_ 2 | #define MIJIA_BLE_LIBS_COMMON_TLV_H_ 3 | 4 | #include 5 | 6 | typedef struct { 7 | uint8_t type; 8 | uint8_t len; 9 | uint8_t value[1]; 10 | } tlv8_t; 11 | 12 | int tlv8_decode(uint8_t * tlv_buf, int buf_size, uint8_t type, tlv8_t **out); 13 | 14 | #endif /* MIJIA_BLE_LIBS_COMMON_TLV_H_ */ 15 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/cryptography/mi_crypto_backend_mbedtls.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIBLE_CRYPTO_BACKEND_MBEDTLS_H__ 2 | #define __MIBLE_CRYPTO_BACKEND_MBEDTLS_H__ 3 | #include 4 | #include 5 | #include "mible_type.h" 6 | 7 | #define PEM_HEADER "-----BEGIN CERTIFICATE-----" 8 | #define PEM_FOOTER "-----END CERTIFICATE-----" 9 | 10 | /** Container for date and time (precision in seconds). */ 11 | typedef struct 12 | { 13 | int year, mon, day; /**< Date. */ 14 | int hour, min, sec; /**< Time. */ 15 | } msc_crt_time; 16 | 17 | typedef struct { 18 | unsigned char *p; 19 | size_t len; 20 | } msc_crt_item_t; 21 | 22 | #define MSC_CRT_SIG_SZ 64 23 | typedef struct { 24 | msc_crt_item_t tbs; /* to be signed */ 25 | msc_crt_item_t pub; /* public key */ 26 | msc_crt_item_t sn; /* serial number */ 27 | msc_crt_item_t sub_o; /* subject O */ 28 | unsigned char sig[MSC_CRT_SIG_SZ]; /* signature */ 29 | } msc_crt_t; 30 | 31 | /** 32 | * @brief x509 DER crt parse 33 | * 34 | * @param raw_crt - input crt in DER format 35 | * @param raw_crt_sz 36 | * @param now - current time in GMT 37 | * @param msc_crt - output parsed crt 38 | * 39 | * @return 0-OK 40 | */ 41 | int mbedtls_crt_parse_der(const unsigned char *raw_crt, size_t raw_crt_sz, 42 | const msc_crt_time *now, 43 | msc_crt_t *msc_crt 44 | ); 45 | int mbedtls_crt_pem2der(const unsigned char *pem, size_t pem_sz, 46 | unsigned char *der_buf, size_t buf_sz); 47 | int mbedtls_read_signature(const unsigned char *sign_der, uint16_t sign_sz, 48 | uint8_t *out_buf, uint16_t out_sz); 49 | 50 | #endif /* __MIBLE_CRYPTO_BACKEND_MSC_H__ END*/ 51 | 52 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/cryptography/mi_crypto_backend_msc.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIBLE_CRYPTO_BACKEND_MSC_H__ 2 | #define __MIBLE_CRYPTO_BACKEND_MSC_H__ 3 | #include 4 | #include "mible_type.h" 5 | 6 | typedef enum { 7 | // Info 8 | MSC_INFO = 0x01, 9 | MSC_ID, 10 | MSC_HIBERNATE, 11 | 12 | // Sign 13 | MSC_SIGN = 0x10, 14 | MSC_VERIFY = 0x11, 15 | 16 | MSC_ECDHE = 0x14, 17 | 18 | MSC_DEV_CERT = 0x20, 19 | MSC_MANU_CERT, 20 | MSC_ROOT_CERT, 21 | MSC_CERTS_LEN = 0x28, 22 | MSC_ROOT_CERT_LEN, 23 | MSC_MANU_CERT_LEN, 24 | MSC_DEV_CERT_LEN, 25 | 26 | MSC_PUBKEY = 0x3B, 27 | 28 | MSC_WR_MKPK = 0x40, 29 | MSC_RD_MKPK, 30 | MSC_ERASE, 31 | 32 | MSC_RANDOM = 0x50, 33 | MSC_STATUS = 0x52, 34 | 35 | MSC_AESCCM_ENC = 0x60, 36 | MSC_AESCCM_DEC, 37 | 38 | MSC_NOP = 0xFF 39 | } msc_cmd_t; 40 | 41 | typedef struct { 42 | uint8_t vid; 43 | uint16_t hw_ver; 44 | uint16_t sw_ver; 45 | uint16_t protocol_ver; 46 | uint8_t cfg; 47 | uint8_t reserve[2]; 48 | uint16_t sn[16]; 49 | uint8_t pad[2]; 50 | } msc_info_t; 51 | 52 | int msc_power_on(void); 53 | int msc_power_off(void); 54 | int mi_msc_config(void * pwr_manage, const iic_config_t * p_iic_config, void *p_timer); 55 | int msc_get_chip_info(msc_info_t *p_info); 56 | int msc_get_device_id(uint8_t did[8]); 57 | int msc_get_cert_len(uint16_t *p_dev_len, uint16_t *p_manu_len, uint16_t *p_root_len); 58 | int msc_get_cert_der(uint8_t cert_type, uint8_t *p_der, uint16_t der_len); 59 | int msc_ecc_keypair_gen(const uint8_t *p_curve, uint8_t *p_pk); 60 | int msc_ecdh(const uint8_t *p_curve, const uint8_t *p_le_pk, uint8_t *p_shared); 61 | int msc_ecdsa_verify(const uint8_t *p_curve, const uint8_t *p_le_pk, 62 | uint8_t const *p_hash, uint8_t const *p_sig); 63 | int msc_ecdsa_sign(const uint8_t *p_curve, const uint8_t *p_hash, uint8_t *p_sig); 64 | int msc_record_write(uint8_t record_id, const uint8_t *p_data, uint8_t len); 65 | int msc_record_read(uint8_t record_id, uint8_t *p_data, uint8_t len); 66 | int msc_record_delete(uint8_t record_id); 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/cryptography/mi_crypto_backend_uECC.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIBLE_CRYPTO_BACKEND_UECC_H__ 2 | #define __MIBLE_CRYPTO_BACKEND_UECC_H__ 3 | #include 4 | #include "../../mijia_ble_api/mible_type.h" 5 | 6 | void micro_ecc_init(void *p_ctx); 7 | int micro_ecc_keypair_gen(void *p_ctx, uint8_t *p_sk, uint8_t *p_pk); 8 | int micro_ecc_public_key_compute(void *p_ctx, uint8_t const *p_sk, uint8_t *p_pk); 9 | int micro_ecc_shared_secret_compute(void *p_ctx, uint8_t const *p_sk, uint8_t const *p_pk, uint8_t *p_ss); 10 | int micro_ecc_sign(void *p_ctx, uint8_t const *p_sk, uint8_t const * p_hash, uint8_t *p_sig); 11 | int micro_ecc_verify(void *p_ctx, uint8_t const *p_pk, uint8_t const * p_hash, uint8_t const *p_sig); 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/cryptography/mi_mesh_otp.h: -------------------------------------------------------------------------------- 1 | #ifndef MIJIA_BLE_LIBS_CRYPTOGRAPHY_MI_MESH_OTP_H_ 2 | #define MIJIA_BLE_LIBS_CRYPTOGRAPHY_MI_MESH_OTP_H_ 3 | #include 4 | #include 5 | 6 | /* OTP_ITEM_TYPE */ 7 | #define OTP_MARK_DIRTY 0x00 8 | #define OTP_DEV_CERT 0x01 9 | #define OTP_MANU_CERT 0x02 10 | #define OTP_ROOT_CERT 0x03 11 | #define OTP_DEV_CERT_PRI 0x04 12 | #define OTP_BLE_MAC 0x10 13 | #define OTP_META_DATA 0xF1 14 | #define OTP_FREE_ITEM 0xFFFF 15 | 16 | typedef int (*uart_sync_tx_t)(uint8_t const * const out, uint16_t olen); 17 | typedef int (*uart_sync_rx_t)(uint8_t * const in, uint16_t max_ilen); 18 | typedef void (*dbg_flash_lock_func_t)(void); 19 | 20 | int mi_mesh_otp_seal_tag(uint8_t * base); 21 | bool mi_mesh_otp_is_existed(void); 22 | int mi_mesh_otp_manufacture_init(uart_sync_tx_t tx, uart_sync_rx_t rx, 23 | dbg_flash_lock_func_t lock_flash_fn, dbg_flash_lock_func_t lock_debug_fn); 24 | int mi_mesh_otp_write(uint16_t item_type, const uint8_t *p_in, uint16_t in_len); 25 | int mi_mesh_otp_read(uint16_t item_type, uint8_t *p_out, uint16_t max_olen); 26 | int mi_mesh_otp_program(void); 27 | int mi_mesh_otp_program_simulation(void); 28 | int mi_mesh_otp_verify(void); 29 | 30 | #endif /* MIJIA_BLE_LIBS_CRYPTOGRAPHY_MI_MESH_OTP_H_ */ 31 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/cryptography/mi_mesh_otp_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mi_mesh_otp_config.h 3 | * 4 | * Created on: 2018年9月18日 5 | * Author: JT 6 | */ 7 | 8 | #ifndef MIJIA_BLE_LIBS_MANUFACTURE_MI_MESH_OTP_CONFIG_H_ 9 | #define MIJIA_BLE_LIBS_MANUFACTURE_MI_MESH_OTP_CONFIG_H_ 10 | 11 | #define POTP_BASE ((uint8_t*)0x7F100UL) 12 | #define POTP_FULL_SIZE 2048 13 | 14 | #endif /* MIJIA_BLE_LIBS_MANUFACTURE_MI_MESH_OTP_CONFIG_H_ */ 15 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/cryptography/mja1/mjac_defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __MJAC_DEFS_H 2 | #define __MJAC_DEFS_H 3 | 4 | /* uncomment for speed */ 5 | /* #define CRC_CCCITT_IN_RAM */ 6 | 7 | typedef unsigned char UINT8; 8 | typedef unsigned short UINT16; 9 | 10 | #ifndef MEMCPY 11 | //#include 12 | #define MEMCPY memcpy 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/cryptography/mja1/mjac_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __MJAC_UTILS_H 2 | #define __MJAC_UTILS_H 3 | #include "mjac_defs.h" 4 | 5 | struct mjac_lv { 6 | UINT16 length; 7 | UINT8 *value; 8 | }; 9 | typedef struct { 10 | struct mjac_lv tbs; 11 | struct mjac_lv pub; 12 | struct mjac_lv sn; 13 | struct mjac_lv sign; 14 | } x509_crt_t; 15 | 16 | extern UINT16 crc16_ccitt(const UINT8 *data, UINT16 sz); 17 | 18 | extern UINT8 x509_crt_parse_der(const UINT8 *der, UINT16 der_sz, x509_crt_t *crt); 19 | 20 | extern UINT16 x509_pubkey_to_mjac( 21 | const UINT8 *pub, UINT16 pub_sz, 22 | UINT8 *out, UINT16 out_sz); 23 | extern UINT16 x509_sign_to_mjac( 24 | const UINT8 *sign, UINT16 sign_sz, 25 | UINT8 *out, UINT16 out_sz); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/gatt_dfu/mible_dfu_auth.h: -------------------------------------------------------------------------------- 1 | /* Define to prevent recursive inclusion -------------------------------------*/ 2 | 3 | #ifndef __MI_DFU_AUTH_H__ 4 | #define __MI_DFU_AUTH_H__ 5 | 6 | /* Includes ------------------------------------------------------------------*/ 7 | 8 | #include "mible_type.h" 9 | 10 | /* Exported types ------------------------------------------------------------*/ 11 | /* Exported constants --------------------------------------------------------*/ 12 | /* Exported functions --------------------------------------------------------*/ 13 | 14 | mible_status_t mible_dfu_auth(uint32_t total_size, uint32_t product_id); 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/gatt_dfu/mible_dfu_flash.h: -------------------------------------------------------------------------------- 1 | /* Define to prevent recursive inclusion -------------------------------------*/ 2 | 3 | #ifndef __MI_DFU_FLASH_H__ 4 | #define __MI_DFU_FLASH_H__ 5 | 6 | /* Includes ------------------------------------------------------------------*/ 7 | 8 | #include "mible_type.h" 9 | 10 | /* Exported functions --------------------------------------------------------*/ 11 | 12 | mible_status_t mible_dfu_flash_init(uint32_t flash_start, uint32_t flash_size); 13 | mible_status_t mible_dfu_flash_read(void * buffer, uint32_t length, uint32_t offset); 14 | mible_status_t mible_dfu_flash_write(void * buffer, uint32_t length, uint32_t offset); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/gatt_dfu/mible_dfu_main.h: -------------------------------------------------------------------------------- 1 | /* Define to prevent recursive inclusion -------------------------------------*/ 2 | 3 | #ifndef __MI_DFU_MAIN_H__ 4 | #define __MI_DFU_MAIN_H__ 5 | 6 | /* Includes ------------------------------------------------------------------*/ 7 | 8 | #include "mible_type.h" 9 | 10 | /* Exported define -----------------------------------------------------------*/ 11 | 12 | /* Exported types ------------------------------------------------------------*/ 13 | 14 | typedef struct { 15 | uint16_t conn_handle; 16 | uint16_t srv_handle; 17 | uint16_t ctrl_handle; 18 | uint16_t data_handle; 19 | uint16_t product_id; 20 | uint32_t flash_start; 21 | uint32_t flash_size; 22 | } mible_dfu_init_t; 23 | 24 | typedef enum { 25 | MIBLE_DFU_STATE_START, 26 | MIBLE_DFU_STATE_VERIFY, 27 | MIBLE_DFU_STATE_SWITCH, 28 | MIBLE_DFU_STATE_CANCEL, 29 | } mible_dfu_state_t; 30 | 31 | typedef enum { 32 | MIBLE_DFU_VERIFY_SUCC, 33 | MIBLE_DFU_VERIFY_FAIL, 34 | } mible_dfu_verify_t; 35 | 36 | typedef struct { 37 | uint16_t fragment_size; 38 | } mible_dfu_start_param_t; 39 | 40 | typedef struct { 41 | mible_dfu_verify_t value; 42 | } mible_dfu_verify_param_t; 43 | 44 | typedef union { 45 | mible_dfu_start_param_t start; 46 | mible_dfu_verify_param_t verify; 47 | } mible_dfu_param_t; 48 | 49 | typedef void (* mible_dfu_callback_t) (mible_dfu_state_t state, mible_dfu_param_t *param); 50 | 51 | /* Exported constants --------------------------------------------------------*/ 52 | /* Exported functions --------------------------------------------------------*/ 53 | 54 | mible_status_t mible_dfu_init(mible_dfu_init_t * p_init); 55 | mible_status_t mible_dfu_ctrl(uint8_t * buffer, uint16_t size); 56 | mible_status_t mible_dfu_data(uint8_t * buffer, uint16_t size); 57 | mible_status_t mible_dfu_upgrade(void); 58 | mible_status_t mible_dfu_callback_register(mible_dfu_callback_t cb); 59 | mible_status_t mible_dfu_callback_unregister(mible_dfu_callback_t cb); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/mijia_profiles/mi_service_server.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010-2017 Xiaomi. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Xiaomi. 4 | * Terms and conditions of usage are described in detail in 5 | * STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup ble_mi Xiaomi Service 16 | * @{ 17 | * @ingroup ble_sdk_srv 18 | * @brief Xiaomi Service implementation. 19 | * 20 | * @details The Xiaomi Service is a simple GATT-based service with many characteristics. 21 | * Data received from the peer is passed to the application, and the data 22 | * from the application of this service is sent to the peer as Handle Value 23 | * Notifications. This module demonstrates how to implement a custom GATT-based 24 | * service and characteristics using the BLE Stack. The service 25 | * is used by the application to send and receive pub_key and MSC Cert from the 26 | * peer. 27 | * 28 | * @note The application must propagate BLE Stack events to the Xiaomi Service module 29 | * by calling the ble_mi_on_ble_evt() function from the ble_stack_handler callback. 30 | */ 31 | 32 | #ifndef __MI_SERVICE_SECURE_H__ 33 | #define __MI_SERVICE_SECURE_H__ 34 | #include 35 | 36 | #define BLE_MI_MAX_DATA_LEN (GATT_MTU_SIZE_DEFAULT - 3) /**< Maximum length of data (in bytes) that can be transmitted to the peer by the Xiaomi service module. */ 37 | 38 | typedef void (* mi_service_evt_handler_t)(uint8_t is_connected); 39 | 40 | /**@brief Function for initializing the Xiaomi Service. 41 | */ 42 | uint32_t mi_service_init(void); 43 | 44 | /* internal api */ 45 | void mi_service_event_register(mi_service_evt_handler_t h); 46 | uint32_t opcode_send(uint32_t status); 47 | uint32_t opcode_recv(void); 48 | 49 | #endif // __MI_SERVICE_SECURE_H__ 50 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/mijia_profiles/stdio_service_server.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010-2017 Xiaomi. All Rights Reserved. 2 | * 3 | * The information contained herein is property of Xiaomi. 4 | * Terms and conditions of usage are described in detail in 5 | * STANDARD SOFTWARE LICENSE AGREEMENT. 6 | * 7 | * Licensees are granted free, non-transferable use of the information. NO 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from 9 | * the file. 10 | * 11 | */ 12 | 13 | /**@file 14 | * 15 | * @defgroup ble_mi Lock Service 16 | * @{ 17 | * @ingroup ble_sdk_srv 18 | * @brief Lock Service implementation. 19 | * 20 | * @details The Lock Service is a simple GATT-based service with many characteristics. 21 | * Data received from the peer is passed to the application, and the data received 22 | * from the application of this service is sent to the peer as Handle Value 23 | * Notifications. This module demonstrates how to implement a custom GATT-based 24 | * service and characteristics using the BLE Stack. The service 25 | * is used by the application to send and receive pub_key and MSC Cert to and from the 26 | * peer. 27 | * 28 | * @note The application must propagate BLE Stack events to the Lock Service module 29 | * by calling the ble_mi_on_ble_evt() function from the ble_stack_handler callback. 30 | */ 31 | 32 | #ifndef __STDIO_SERVICE_H__ 33 | #define __STDIO_SERVICE_H__ 34 | #include 35 | #include "mible_port.h" 36 | 37 | #define BLE_MI_MAX_DATA_LEN (GATT_MTU_SIZE_DEFAULT - 3) /**< Maximum length of data (in bytes) that can be transmitted to the peer by the Xiaomi service module. */ 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | /**@brief stdio Service event handler type. */ 44 | typedef void (*stdio_rx_t) (uint8_t* p, uint8_t l); 45 | 46 | 47 | /**@brief Function for initializing the stdio Service. 48 | * 49 | * @param[in] rx_handler receive data callback 50 | * 51 | * @retval NRF_SUCCESS If the service was successfully initialized. Otherwise, an error code is returned. 52 | * @retval NRF_ERROR_NULL If either of the pointers p_mi_s or p_mi_s_init is NULL. 53 | */ 54 | int stdio_service_init(stdio_rx_t rx_handler); 55 | 56 | 57 | /**@brief Send data. 58 | * 59 | * @param[in] vlen : the length of EVENT value. 60 | * @param[in] value: Pointer to the formated LOCK EVENT value. 61 | * 62 | * @retval 0 : successful respond the status. 63 | * -1 : BLE_CONN_HANDLE_INVALID 64 | * -2 : PEER NOT LOGIN. 65 | * -3 : BLE STACK BUSY. 66 | */ 67 | int stdio_tx(void *data, uint8_t len); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif // __STDIO_SERVICE_H__ 74 | 75 | /** @} */ 76 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/third_party/mbedtls/config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \brief Configuration options (set of defines) 3 | * 4 | * This set of compile-time options may be used to enable 5 | * or disable features selectively, and reduce the global 6 | * memory footprint. 7 | * 8 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 9 | * SPDX-License-Identifier: Apache-2.0 10 | * 11 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 12 | * not use this file except in compliance with the License. 13 | * You may obtain a copy of the License at 14 | * 15 | * http://www.apache.org/licenses/LICENSE-2.0 16 | * 17 | * Unless required by applicable law or agreed to in writing, software 18 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 19 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | * See the License for the specific language governing permissions and 21 | * limitations under the License. 22 | * 23 | * This file is part of mbed TLS (https://tls.mbed.org) 24 | */ 25 | 26 | #ifndef MBEDTLS_CONFIG_H 27 | #define MBEDTLS_CONFIG_H 28 | 29 | #define MBEDTLS_CIPHER_MODE_CTR 1 30 | 31 | #define MSC_CIPHER_CRT_DER 1 32 | #define MSC_CIPHER_PEM 0 33 | #define MSC_CIPHER_SHA 1 34 | #define MSC_CIPHER_HKDF 1 35 | #define MSC_CIPHER_AES 1 36 | #define MSC_CIPHER_ECDH 0 37 | #define MSC_CIPHER_ECDSA 0 38 | 39 | #if (MSC_CIPHER_CRT_DER == 1) 40 | #define MBEDTLS_ASN1_PARSE_C 41 | #endif 42 | #if (MSC_CIPHER_PEM == 1) 43 | #define MBEDTLS_BASE64_C 44 | #endif 45 | #if (MSC_CIPHER_SHA) || (MSC_CIPHER_HKDF) 46 | #define MBEDTLS_SHA256_C 47 | #endif 48 | #if (MSC_CIPHER_HKDF) 49 | #define MBEDTLS_MD_C 50 | #endif 51 | 52 | #if (MSC_CIPHER_AES) 53 | #define MBEDTLS_CIPHER_C 54 | #define MBEDTLS_AES_C 55 | #define MBEDTLS_CCM_C 56 | #endif 57 | 58 | #if (MSC_CIPHER_ECDSA) || (MSC_CIPHER_ECDH) 59 | #define MBEDTLS_ECP_C 60 | #define MBEDTLS_ECP_DP_SECP256R1_ENABLED 61 | #define MBEDTLS_BIGNUM_C 62 | #endif 63 | 64 | #if (MSC_CIPHER_ECDH) 65 | #define MBEDTLS_ECDH_C 66 | #endif 67 | 68 | #if (MSC_CIPHER_ECDSA) 69 | #ifndef MBEDTLS_ASN1_PARSE_C 70 | #define MBEDTLS_ASN1_PARSE_C 71 | #endif 72 | #define MBEDTLS_ASN1_WRITE_C 73 | #define MBEDTLS_ECDSA_C 74 | #endif 75 | 76 | #define MBEDTLS_CMAC_C 77 | 78 | #if defined(MBEDTLS_ALT_CONFIG_FILE) 79 | #include MBEDTLS_ALT_CONFIG_FILE 80 | #endif 81 | 82 | #include "check_config.h" 83 | 84 | #endif /* MBEDTLS_CONFIG_H */ 85 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/third_party/mbedtls/sha256_hkdf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file mbedtls_sha256.h 3 | * 4 | * \brief SHA-224 and SHA-256 cryptographic hash function 5 | * 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 7 | * SPDX-License-Identifier: Apache-2.0 8 | * 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 10 | * not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * This file is part of mbed TLS (https://tls.mbed.org) 22 | */ 23 | #ifndef MBEDTLS_SHA256_HKDF_H 24 | #define MBEDTLS_SHA256_HKDF_H 25 | 26 | unsigned int mbedtls_sha256_hkdf(const unsigned char *key, unsigned int key_len, const unsigned char *salt, unsigned int salt_len, 27 | const unsigned char *info, unsigned int info_len, unsigned char *out, unsigned int out_len); 28 | 29 | #endif /* mbedtls_sha256.h */ 30 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/third_party/micro-ecc/types.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2015, Kenneth MacKay. Licensed under the BSD 2-clause license. */ 2 | 3 | #ifndef _UECC_TYPES_H_ 4 | #define _UECC_TYPES_H_ 5 | 6 | #ifndef uECC_PLATFORM 7 | #define uECC_PLATFORM uECC_arch_other 8 | #endif 9 | 10 | #ifndef uECC_ARM_USE_UMAAL 11 | #if (uECC_PLATFORM == uECC_arm) && (__ARM_ARCH >= 6) 12 | #define uECC_ARM_USE_UMAAL 1 13 | #elif (uECC_PLATFORM == uECC_arm_thumb2) && (__ARM_ARCH >= 6) && !__ARM_ARCH_7M__ 14 | #define uECC_ARM_USE_UMAAL 1 15 | #else 16 | #define uECC_ARM_USE_UMAAL 0 17 | #endif 18 | #endif 19 | 20 | #ifndef uECC_WORD_SIZE 21 | #if uECC_PLATFORM == uECC_avr 22 | #define uECC_WORD_SIZE 1 23 | #elif (uECC_PLATFORM == uECC_x86_64 || uECC_PLATFORM == uECC_arm64) 24 | #define uECC_WORD_SIZE 8 25 | #else 26 | #define uECC_WORD_SIZE 4 27 | #endif 28 | #endif 29 | 30 | #if (uECC_WORD_SIZE != 1) && (uECC_WORD_SIZE != 4) && (uECC_WORD_SIZE != 8) 31 | #error "Unsupported value for uECC_WORD_SIZE" 32 | #endif 33 | 34 | #if ((uECC_PLATFORM == uECC_avr) && (uECC_WORD_SIZE != 1)) 35 | #pragma message ("uECC_WORD_SIZE must be 1 for AVR") 36 | #undef uECC_WORD_SIZE 37 | #define uECC_WORD_SIZE 1 38 | #endif 39 | 40 | #if ((uECC_PLATFORM == uECC_arm || uECC_PLATFORM == uECC_arm_thumb || \ 41 | uECC_PLATFORM == uECC_arm_thumb2) && \ 42 | (uECC_WORD_SIZE != 4)) 43 | #pragma message ("uECC_WORD_SIZE must be 4 for ARM") 44 | #undef uECC_WORD_SIZE 45 | #define uECC_WORD_SIZE 4 46 | #endif 47 | 48 | #if defined(__SIZEOF_INT128__) || ((__clang_major__ * 100 + __clang_minor__) >= 302) 49 | #define SUPPORTS_INT128 1 50 | #else 51 | #define SUPPORTS_INT128 0 52 | #endif 53 | 54 | typedef int8_t wordcount_t; 55 | typedef int16_t bitcount_t; 56 | typedef int8_t cmpresult_t; 57 | 58 | #if (uECC_WORD_SIZE == 1) 59 | 60 | typedef uint8_t uECC_word_t; 61 | typedef uint16_t uECC_dword_t; 62 | 63 | #define HIGH_BIT_SET 0x80 64 | #define uECC_WORD_BITS 8 65 | #define uECC_WORD_BITS_SHIFT 3 66 | #define uECC_WORD_BITS_MASK 0x07 67 | 68 | #elif (uECC_WORD_SIZE == 4) 69 | 70 | typedef uint32_t uECC_word_t; 71 | typedef uint64_t uECC_dword_t; 72 | 73 | #define HIGH_BIT_SET 0x80000000 74 | #define uECC_WORD_BITS 32 75 | #define uECC_WORD_BITS_SHIFT 5 76 | #define uECC_WORD_BITS_MASK 0x01F 77 | 78 | #elif (uECC_WORD_SIZE == 8) 79 | 80 | typedef uint64_t uECC_word_t; 81 | #if SUPPORTS_INT128 82 | typedef unsigned __int128 uECC_dword_t; 83 | #endif 84 | 85 | #define HIGH_BIT_SET 0x8000000000000000ull 86 | #define uECC_WORD_BITS 64 87 | #define uECC_WORD_BITS_SHIFT 6 88 | #define uECC_WORD_BITS_MASK 0x03F 89 | 90 | #endif /* uECC_WORD_SIZE */ 91 | 92 | #endif /* _UECC_TYPES_H_ */ 93 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/libs/third_party/pt/pt_misc.h: -------------------------------------------------------------------------------- 1 | #ifndef __PT_MISC_H__ 2 | #define __PT_MISC_H__ 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /*** Pseudo timer ***/ 11 | typedef struct { 12 | uint32_t * p_curr_tick; 13 | uint32_t tick_interval_ms; 14 | uint32_t start_tick; 15 | uint32_t timeout_tick; 16 | } pstimer_t; 17 | 18 | void pstimer_set(pstimer_t * t, uint32_t timeout_ms); 19 | 20 | int pstimer_expired(pstimer_t * t, void (*timeout_handler)(void)); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | /** @} */ 27 | 28 | #endif /* __PT_MISC_H__ */ 29 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/mijia_ble_api/mible_trace.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIBLE_TRACE_H__ 2 | #define __MIBLE_TRACE_H__ 3 | 4 | /* DWT (Data Watchpoint and Trace) registers, only exists on ARM Cortex-M3 above with a DWT unit */ 5 | #ifdef DWT 6 | #define DWT_CYCCNTENA_BIT (1UL<<0) 7 | #define TRCENA_BIT (1UL<<24) 8 | 9 | /*!< TRCENA: Enable trace and debug block DEMCR (Debug Exception and Monitor Control Register */ 10 | 11 | #define InitCycleCounter() \ 12 | CoreDebug->DEMCR |= TRCENA_BIT 13 | 14 | #define ResetCycleCounter() \ 15 | DWT->CYCCNT = 0 16 | 17 | #define EnableCycleCounter() \ 18 | DWT->CTRL |= DWT_CYCCNTENA_BIT 19 | 20 | #define DisableCycleCounter() \ 21 | DWT->CTRL &= ~DWT_CYCCNTENA_BIT 22 | 23 | #define GetCycleCounter() \ 24 | (DWT->CYCCNT) 25 | #else 26 | #define InitCycleCounter() 27 | #define ResetCycleCounter() 28 | #define EnableCycleCounter() 29 | #define DisableCycleCounter() 30 | #define GetCycleCounter() 31 | #endif /* DWT END*/ 32 | 33 | #if TIME_PROFILE 34 | #define TIMING_INIT() \ 35 | InitCycleCounter() 36 | 37 | #define TIMING_BEGIN() \ 38 | ResetCycleCounter() 39 | 40 | #define TIMING_END(name) \ 41 | MI_LOG_DEBUG("%s consume time: %u us\n", (char*)name, GetCycleCounter()/(SystemCoreClock/1000000)) 42 | #else 43 | #define TIMING_INIT() 44 | #define TIMING_BEGIN() 45 | #define TIMING_END(name) 46 | #endif 47 | 48 | static uint32_t ref_tick; 49 | static uint32_t cpu_clk = 38400000; 50 | 51 | static __INLINE void init_time_profile(uint8_t cpu_running_hz) 52 | { 53 | if (cpu_running_hz > 0 ) 54 | cpu_clk = cpu_running_hz; 55 | 56 | InitCycleCounter(); 57 | ResetCycleCounter(); 58 | EnableCycleCounter(); 59 | } 60 | 61 | static __INLINE void set_time_ref() 62 | { 63 | //ref_tick = GetCycleCounter(); 64 | } 65 | 66 | static __INLINE uint32_t us_from_time_ref() 67 | { 68 | return (GetCycleCounter() - ref_tick) * 10 / 384; 69 | } 70 | 71 | #endif /* __MIBLE_TRACE_H__ */ 72 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/mi_api/mijia_pub_proc.h: -------------------------------------------------------------------------------- 1 | #ifndef _MIJIA_PUB_PROC_C_ 2 | #define _MIJIA_PUB_PROC_C_ 3 | #include "./mijia_ble_api/mible_api.h" 4 | #include "proj/tl_common.h" 5 | #include "proj_lib/ble/ll/ll.h" 6 | #include "proj_lib/ble/blt_config.h" 7 | #include "vendor/common/user_config.h" 8 | #include "proj_lib/ble/service/ble_ll_ota.h" 9 | #include "../app_health.h" 10 | //#include "proj_lib/sig_mesh/app_mesh.h" 11 | #include "proj_lib/mesh_crypto/le_crypto.h" 12 | //#include "../../../proj_lib/mesh_crypto/ecc_dsa.h" 13 | #include "../mesh_common.h" 14 | #include "../ev.h" 15 | #include "./libs/third_party/micro-ecc/uECC.h" 16 | #include "./libs/third_party/micro-ecc/types.h" 17 | 18 | typedef struct { 19 | u8 mode; 20 | u8 model_idx; 21 | u8 sts_pub_inter; 22 | u8 sts_pub_1st; 23 | // the unit is 100ms 24 | u32 last_100ms; 25 | u32 inter_100ms; 26 | u32 max_pub_100ms; 27 | u32 sts_change_100ms; 28 | model_common_t * p_model; 29 | // max pub units is s; 30 | u32 mp_inter; 31 | u32 mp_last_sec; 32 | u8 mp_rsp_flag; 33 | u8 mp_send_flag; 34 | u8 retry_cnt; 35 | }mi_pub_str_t; 36 | 37 | 38 | extern mi_pub_str_t mi_pub; 39 | u8 pub_step_proc_cb(u8 sts_flag,model_common_t *p_model,u32 model_id); 40 | void pub_max_inter_rcv_cb(u8 max_pub); 41 | void mi_pub_clear_trans_flag(); 42 | void mi_pub_send_all_status(); 43 | void mi_pub_para_init(mi_pub_str_t *p_mi_pub); 44 | void mi_pub_vd_sig_para_init(); 45 | void mi_pub_sigmodel_inter(u8 trans,u8 delay,u8 mode); 46 | 47 | 48 | 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/myprintf.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file myprintf.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #ifndef MYPRINTF_H 23 | #define MYPRINTF_H 24 | 25 | #define SIMU_BAUD_115200 115200 26 | #define SIMU_BAUD_230400 230400 27 | #define SIMU_BAUD_1M 1000000 28 | 29 | #define BAUD_USE SIMU_BAUD_1M 30 | #define SIMU_UART_IRQ_EN (1&&!blcOta.ota_start_flag) 31 | 32 | 33 | extern void uart_simu_send_bytes(u8 *p,int len); 34 | //#define debugBuffer (*(volatile unsigned char (*)[40])(0x8095d8)) 35 | #endif 36 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/system_time.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file system_time.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj/tl_common.h" 26 | 27 | 28 | extern u32 system_time_ms; 29 | extern u32 system_time_100ms; 30 | extern u32 system_time_s; 31 | 32 | static inline u32 clock_time_ms(){ 33 | return system_time_ms; 34 | } 35 | 36 | static inline u32 clock_time_100ms(){ 37 | return system_time_100ms; 38 | } 39 | 40 | static inline u32 clock_time_s(){ 41 | return system_time_s; 42 | } 43 | 44 | void system_time_run(); 45 | u32 clock_time_exceed_ms(u32 ref, u32 span_ms); 46 | u32 clock_time_exceed_100ms(u32 ref, u32 span_100ms); 47 | u32 clock_time_exceed_s(u32 ref, u32 span_s); 48 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/user_ali.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_ALI_H 2 | #define __USER_ALI_H 3 | #include "../../proj/tl_common.h" 4 | #include "../../proj_lib/ble/ll/ll.h" 5 | #include "../../proj_lib/ble/blt_config.h" 6 | #include "../../vendor/common/user_config.h" 7 | 8 | typedef struct{ 9 | //u8 rev; 10 | u16 cid; 11 | union{ 12 | u8 pid; 13 | struct{ 14 | u8 adv_ver:4; 15 | u8 ser_fun:1; 16 | u8 ota_en:1; 17 | u8 ble_ver:2; 18 | }; 19 | }; 20 | u8 product_id[4]; 21 | u8 mac[6]; 22 | union{ 23 | u8 feature_flag; 24 | struct{ 25 | u8 adv_flag:1; 26 | u8 uuid_ver:7; 27 | }; 28 | }; 29 | u8 rfu[2]; 30 | }sha256_dev_uuid_str; 31 | 32 | typedef struct{ 33 | u8 auth_ok; 34 | u8 ble_key[16]; 35 | }ais_gatt_auth_t; 36 | 37 | extern ais_gatt_auth_t ais_gatt_auth; 38 | extern const u8 iv[]; 39 | 40 | void set_sha256_init_para_mode(u8 mode); 41 | void set_dev_uuid_for_sha256(); 42 | void create_sha256_input_string(char *p_input,u8 *pid,u8 *p_mac,u8 *p_secret); 43 | void create_sha256_input_string_node(char *p_input,u8 *pid,u8 *p_mac,u8 *p_secret); 44 | void caculate_sha256_to_create_static_oob(); 45 | void caculate_sha256_to_create_pro_oob(u8 *pro_auth,u8 *random); 46 | void caculate_sha256_node_auth_value(u8 *auth_value); 47 | int ais_write_pipe(void *p); 48 | void ais_gatt_auth_init(); 49 | void caculate_sha256_node_oob(u8 *p_oob ,u8 *p_random); 50 | void mesh_ais_global_var_set(); 51 | void calculate_auth_value(); 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/user_ali_time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * vd_md_time_ali.h 3 | * 4 | * Created on: 2019-11-6 5 | * Author: ZHAN 6 | */ 7 | 8 | #ifndef VD_MD_TIME_ALI_H_ 9 | #define VD_MD_TIME_ALI_H_ 10 | 11 | #include "../../proj/tl_common.h" 12 | #include "../../proj_lib/sig_mesh/app_mesh.h" 13 | 14 | #endif /* VD_MD_TIME_ALI_H_ */ 15 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/user_config.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file user_config.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj/mcu/config.h" 26 | 27 | 28 | #if (__TUYA_PROJECT__) 29 | #if(MCU_CORE_TYPE == MCU_CORE_8269) 30 | #include "../base/app_config_8269.h" 31 | #elif(MCU_CORE_TYPE == MCU_CORE_8258) 32 | #include "../base/app_config_8258.h" 33 | #endif 34 | #else 35 | #if(MCU_CORE_TYPE == MCU_CORE_8269) 36 | #include "../mesh/app_config_8269.h" 37 | #elif(MCU_CORE_TYPE == MCU_CORE_8258) 38 | #include "../mesh/app_config_8258.h" 39 | #elif(MCU_CORE_TYPE == MCU_CORE_8278) 40 | #include "../mesh/app_config_8278.h" 41 | #endif 42 | #endif 43 | 44 | 45 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/user_proc.h: -------------------------------------------------------------------------------- 1 | #ifndef __USER_PROC_H 2 | #define __USER_PROC_H 3 | #include "../../proj/tl_common.h" 4 | #include "../../proj_lib/ble/ll/ll.h" 5 | #include "../../proj_lib/ble/blt_config.h" 6 | #include "../../vendor/common/user_config.h" 7 | #include "user_ali.h" 8 | //#include "nl_api/nl_common.h" 9 | 10 | u8 ais_pri_data_set(u8 *p); 11 | void user_sha256_data_proc(); 12 | void user_node_oob_set(); 13 | u8 user_mac_proc(); 14 | void user_power_on_proc(); 15 | void user_mesh_cps_init(); 16 | void user_set_def_sub_adr(); 17 | void user_system_time_proc(); 18 | void mesh_provision_para_init(u8 *p_random); 19 | void user_prov_multi_oob(); 20 | void user_prov_multi_device_uuid(); 21 | int user_node_rc_link_open_callback(); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/vendor_model.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file vendor_model.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | 23 | #pragma once 24 | 25 | #include "../../proj/tl_common.h" 26 | 27 | // vendor model id 28 | 29 | #define TEMP_VD_ID_MODEL (VENDOR_ID) 30 | 31 | #define VENDOR_MD_TUYA_S ((0x0004<<16) | (TEMP_VD_ID_MODEL)) 32 | #define VENDOR_MD_TUYA_C ((0x0005<<16) | (TEMP_VD_ID_MODEL)) -------------------------------------------------------------------------------- /includes/board/chip/telink_sig_mesh_sdk/sdk/vendor/common/version.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************************************** 2 | * @file version.h 3 | * 4 | * @brief for TLSR chips 5 | * 6 | * @author telink 7 | * @date Sep. 30, 2010 8 | * 9 | * @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd. 10 | * All rights reserved. 11 | * 12 | * The information contained herein is confidential and proprietary property of Telink 13 | * Semiconductor (Shanghai) Co., Ltd. and is available under the terms 14 | * of Commercial License Agreement between Telink Semiconductor (Shanghai) 15 | * Co., Ltd. and the licensee in separate contract or the terms described here-in. 16 | * This heading MUST NOT be removed from this file. 17 | * 18 | * Licensees are granted free, non-transferable use of the information in this 19 | * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided. 20 | * 21 | *******************************************************************************************************/ 22 | #pragma once 23 | 24 | // can't use "enum" here, because cstartup.S not support 25 | 26 | //#define BUILD_VERSION "Revision: 45:49M" 27 | //#define BUILD_TIME "2012-07-24-21:37:43" 28 | 29 | #include "../../proj/mcu/config.h" 30 | #include "mesh_config.h" 31 | 32 | 33 | #define PID_UNKNOW (0x0000) 34 | // ------ light ------ 35 | // LIGHT_TYPE_SEL_ 36 | // ------ gateway ------ 37 | #define PID_GATEWAY (0x0101) 38 | // ------ LPN ------ 39 | #define PID_LPN (0x0201) 40 | // ------ SWITCH ------ 41 | #define PID_SWITCH (0x0301) 42 | // ------ SPIRIT_LPN ------ 43 | #define PID_SPIRIT_LPN (0x0401) 44 | 45 | /* 46 | MESH_PID_SEL : PID is product ID, 47 | MESH_VID: VID is software version ID, 48 | 49 | PID and VID are used in composition data: model_sig_cfg_s_cps. 50 | format: please refer to spec "4.2.1.1 Composition Data Page 0" 51 | */ 52 | 53 | #define MESH_PID_SEL (0x0000) 54 | 55 | #define MESH_PID_REAL MESH_PID_SEL 56 | 57 | // -- 58 | #define RUN_254K_IN_20000_EN 0 // enable to run 254K in 0x20000(default is 124k), disable to save RAM 59 | 60 | #define MCU_RUN_SRAM_WITH_CACHE_EN 0 // 61 | 62 | #define MCU_RUN_SRAM_EN 0 // manual set data address in boot.link.can't read flash by pointer 63 | 64 | 65 | #define MCU_STACK_INIT_EN (1) 66 | 67 | -------------------------------------------------------------------------------- /includes/board/hal/hal_clock.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_clock.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 03 Jul 2019 22:09:57 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_CLOCK_H 9 | #define _HAL_CLOCK_H 10 | 11 | #include "hal_sys.h" 12 | 13 | #define HAL_CLOCK_HZ CLOCK_SYS_CLOCK_HZ 14 | 15 | enum{ 16 | //how much 1us = ? ticks 17 | HAL_CLOCK_1S_TICKS = HAL_CLOCK_HZ, 18 | HAL_CLOCK_1MS_TICKS = (HAL_CLOCK_1S_TICKS / 1000), 19 | HAL_CLOCK_1US_TICKS = (HAL_CLOCK_1MS_TICKS / 1000), 20 | }; 21 | 22 | extern u32 hal_clock_get_system_tick(void); 23 | extern u32 hal_clock_time_exceed(u32 ref, u32 span_us); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /includes/board/hal/hal_encrypt.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_encrypt.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 07 Jun 2018 08:32:09 PM CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_ENCRYPT_H 9 | #define _HAL_ENCRYPT_H 10 | 11 | #include "hal_sys.h" 12 | 13 | void hal_md5(unsigned char *in, int len, unsigned char *out); 14 | 15 | u8 hal_aes_ecb_encryption(u8 *key, u8 mStrLen, u8 *mStr, u8 *result); 16 | u8 hal_aes_ccm_encryption(u8 *key, u8 *iv, u8 *aStr, u8 *mic, u8 mStrLen, u8 *mStr, u8 *result); 17 | u8 hal_aes_ccm_decryption(u8 *key, u8 *iv, u8 *aStr, u8 *mic, u8 mStrLen, u8 *mStr, u8 *result); 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /includes/board/hal/hal_flash.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_linux_flash.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 21 Feb 2019 14:57:34 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_FLASH_H 9 | #define _HAL_FLASH_H 10 | 11 | #include "hal_sys.h" 12 | 13 | extern void hal_flash_init(void); 14 | extern u8 hal_flash_erase_sector(u32 addr); 15 | extern u8 hal_flash_write_page(u32 addr, u32 len, const u8 *buf); 16 | extern u8 hal_flash_read_page(u32 addr, u32 len, u8 *buf); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /includes/board/hal/hal_hw_timer.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: phy_tlsr825x_hw_timer.h 3 | > Author: jiangjj 4 | > Mail: 5 | > Created Time: Fri 26 jul 2019 10:26:19 CST 6 | ************************************************************************/ 7 | #ifndef _HAL_HW_TIMER_H 8 | #define _HAL_HW_TIMER_H 9 | 10 | #include "hal_sys.h" 11 | 12 | 13 | #ifdef TLSR825X_SYS 14 | 15 | enum timer_src_num 16 | { 17 | HAL_TIMER_0 = 0, 18 | HAL_TIMER_1 = 1, 19 | HAL_TIMER_2 = 2, 20 | }; 21 | 22 | typedef int (*hal_hw_timer_callback_t)(void); 23 | 24 | 25 | int hal_hw_timer_cfg(u32 timerId, u32 interval_us, hal_hw_timer_callback_t func); 26 | int hal_imer_stop(u32 timerId); 27 | 28 | void hal_hw_timer_handler(); 29 | 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /includes/board/hal/hal_irq.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_irq.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 07 Mar 2019 18:15:57 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_IRQ_H 9 | #define _HAL_IRQ_H 10 | 11 | #include "hal_sys.h" 12 | 13 | extern u8 hal_irq_enable(void); 14 | extern u8 hal_irq_disable(void); 15 | extern void hal_irq_restore(u8 en); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /includes/board/hal/hal_log.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_log.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 03 Jul 2019 22:05:09 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_LOG_H 9 | #define _HAL_LOG_H 10 | 11 | #include "hal_sys.h" 12 | 13 | void app_log_dump(uint8_t *title, uint8_t *buffer, uint16_t len); 14 | 15 | #if CONFIG_LOG_ON 16 | #define APP_LOG(format,...) app_printf(format, ##__VA_ARGS__) 17 | #define APP_LOG_DUMP(title, buffer, len) app_log_dump(title, buffer, len) 18 | #else 19 | #define APP_LOG(format,...) 20 | #define APP_LOG_DUMP(title, buffer, len) 21 | #endif 22 | 23 | 24 | #if 0 25 | #define PR_DEBUG(_fmt_, ...) \ 26 | app_printf("[dbg]%-30s:%d "_fmt_,__FUNCTION__,__LINE__,##__VA_ARGS__) 27 | #define PR_DEBUG_RAW(_fmt_, ...) \ 28 | app_printf(_fmt_,##__VA_ARGS__) 29 | #define PR_DEBUG_HEX_ARRAY(array,len) do{ \ 30 | if((len) == 0)break; \ 31 | app_printf("%02X",(array)[0]); \ 32 | for(u8 i=1;i<(len);i++){\ 33 | app_printf(" %02X",(array)[i]); \ 34 | } \ 35 | }while(0) 36 | 37 | #else 38 | #define PR_DEBUG(...) 39 | #define PR_DEBUG_RAW(_fmt_, ...) 40 | #define PR_DEBUG_HEX_ARRAY(data,len) 41 | #endif 42 | 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /includes/board/hal/hal_pwm.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_pwm.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 03 Apr 2019 21:17:50 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_PWM_H 9 | #define _HAL_PWM_H 10 | 11 | #include "hal_sys.h" 12 | 13 | #define hal_pwm_set(a, b, c) pwm_set(a, b, c) 14 | #define HAL_GET_PWMID(gpio, func) GET_PWMID(gpio, func) 15 | #define HAL_GET_PWM_INVERT_VAL(gpio, func) GET_PWM_INVERT_VAL(gpio, func) 16 | 17 | void hal_pwm_start(pwm_id id); 18 | void hal_pwm_stop(pwm_id id); 19 | void hal_pwm_revert(pwm_id id); 20 | void hal_pwm_n_revert(pwm_id id); 21 | void hal_pwm_set_cmp(pwm_id id, unsigned short cmp_tick); 22 | 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /includes/board/hal/hal_sleep.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_sleep.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 03 Apr 2019 21:17:50 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_SLEEP_H 9 | #define _HAL_SLEEP_H 10 | 11 | #include "hal_sys.h" 12 | 13 | 14 | typedef enum{ 15 | hal_Level_Low=0, 16 | hal_Level_High =1, 17 | }hal_GPIO_Level_t; 18 | 19 | typedef enum { 20 | //available mode for customer 21 | HAL_SUSPEND_MODE = 0, 22 | 23 | HAL_DEEPSLEEP_MODE = 0x80, 24 | HAL_DEEPSLEEP_MODE_RET_SRAM_LOW16K = 0x43, //for boot from sram 25 | HAL_DEEPSLEEP_MODE_RET_SRAM_LOW32K = 0x07, //for boot from sram 26 | 27 | //not available mode 28 | HAL_DEEPSLEEP_RETENTION_FLAG = 0x7F, 29 | }hal_SleepMode_t; 30 | 31 | typedef enum { 32 | //available wake-up source for customer 33 | HAL_PM_WAKEUP_PAD = BIT(4), HAL_SUSPENDWAKEUP_SRC_PAD = BIT(4), HAL_DEEPWAKEUP_SRC_PAD = BIT(4), 34 | HAL_PM_WAKEUP_CORE = BIT(5), 35 | HAL_PM_WAKEUP_TIMER = BIT(6), HAL_SUSPENDWAKEUP_SRC_TIMER= BIT(6), HAL_DEEPWAKEUP_SRC_TIMER = BIT(6), 36 | //not available wake-up source for customer 37 | HAL_PM_TIM_RECOVER_START = BIT(14), 38 | HAL_PM_TIM_RECOVER_END = BIT(15), 39 | }hal_wakeup_set_t; 40 | 41 | 42 | typedef enum { 43 | HAL_WAKEUP_FROM_POWER = 0x00, 44 | HAL_WAKEUP_FROM_TIMER, 45 | HAL_WAKEUP_FROM_PIN_PAD, 46 | }hal_wakeup_src_t; 47 | 48 | hal_wakeup_src_t hal_get_wakeup_src(void); 49 | int hal_cpu_sleep_wakeup(hal_SleepMode_t deepsleep, hal_wakeup_set_t wakeup_src, u32 wakeup_tick); 50 | void hal_gpio_set_wakeup(u32 pin, hal_GPIO_Level_t level, int en); 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /includes/board/hal/hal_sys.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_sys.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 07 Jun 2018 08:31:44 PM CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_SYS_H 9 | #define _HAL_SYS_H 10 | 11 | 12 | 13 | 14 | #include "mesh_common.h" 15 | #include "flash.h" 16 | #include "gpio_8258.h" 17 | #include "uart.h" 18 | #include "pwm.h" 19 | 20 | #include "hal_log.h" 21 | #include "hal_types.h" 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /includes/board/hal/hal_types.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_types.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 03 Jul 2019 22:04:56 CST 6 | ************************************************************************/ 7 | #ifndef _HAL_TYPES_H 8 | #define _HAL_TYPES_H 9 | 10 | 11 | /* 12 | * type def 13 | */ 14 | #if 0 15 | typedef unsigned char u8; 16 | typedef unsigned short u16; 17 | typedef unsigned int u32; 18 | 19 | typedef char s8; 20 | typedef short s16; 21 | typedef int s32; 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /includes/board/hal/hal_uart.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hal_uart.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 07 Jun 2018 08:32:09 PM CST 6 | ************************************************************************/ 7 | 8 | #ifndef _HAL_UART_H 9 | #define _HAL_UART_H 10 | 11 | #include "hal_sys.h" 12 | 13 | typedef enum{ 14 | BAUD_RATE_9600, 15 | BAUD_RATE_19200, 16 | BAUD_RATE_115200, 17 | }BAUD_TYPE_t; 18 | 19 | #define GPIO_UART0_TX GPIO_PB1 20 | #define GPIO_UART0_RX GPIO_PB7 21 | #define GPIO_UART1_TX GPIO_PB1 //for BT8C 22 | #define GPIO_UART1_RX GPIO_PB0 23 | 24 | extern int hal_uart_init(BAUD_TYPE_t baud_rate, u32 pin_tx, u32 pin_rx); 25 | extern int hal_uart_send(u8 *datas, u8 length); 26 | extern int hal_uart_read(u8 *datas, u8 length); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /includes/components/ty_fifo.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ty_fifo.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 10 May 2018 04:50:21 PM CST 6 | ************************************************************************/ 7 | 8 | #ifndef _TY_FIFO_H 9 | #define _TY_FIFO_H 10 | 11 | #include "board.h" 12 | 13 | #define ElementType u8 //存储数据元素的类型 14 | 15 | extern void ty_fifo_init(void); 16 | extern u8 ty_fifo_isfull(void); 17 | extern u8 ty_fifo_isempty(void); 18 | extern u8 ty_fifo_clean(void); 19 | extern u8 ty_fifo_get_size(void); 20 | extern u8 ty_fifo_add_one(ElementType mdata); 21 | extern u8 ty_fifo_add(ElementType *pdata,u8 len); 22 | extern u8 ty_fifo_read(ElementType *pdata,u8 len); 23 | extern u8 ty_fifo_pop(u8 len); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /includes/components/ty_gpio_base_test.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ty_gpio_base_test.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Tue 26 Mar 2019 15:11:13 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _TY_GPIO_BASE_TEST_H 9 | #define _TY_GPIO_BASE_TEST_H 10 | 11 | #include "board.h" 12 | 13 | 14 | #define MAX_GPIO_TEST_PIN 10 15 | #define MAX_GPIO_TEST_PIN_MORE (MAX_GPIO_TEST_PIN + 1) //=8+1 16 | 17 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) 18 | 19 | 20 | typedef struct{ 21 | u8 pin_num; 22 | u32 pin[MAX_GPIO_TEST_PIN]; 23 | u8 map[MAX_GPIO_TEST_PIN]; 24 | u8 ret[MAX_GPIO_TEST_PIN_MORE]; 25 | }ty_gpio_base_test_s; 26 | 27 | typedef struct{ 28 | u8 num; 29 | u32 pin; 30 | }num2pin_t; 31 | 32 | 33 | extern u8 ty_gpio_base_test_auto(u8 *para, u8 len); 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /includes/components/ty_rssi_base_test.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ty_rssi_base_test.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 27 Mar 2019 14:58:14 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _TY_RSSI_BASE_TEST_H 9 | #define _TY_RSSI_BASE_TEST_H 10 | 11 | #include "board.h" 12 | 13 | typedef void (*CallBackS)(void); 14 | 15 | // 注册start和stop回调函数,方便应用层逻辑在此时做应用层处理 16 | extern void ty_rssi_base_test_register_start_stop_cb(CallBackS start_cb,CallBackS stop_cb); 17 | 18 | extern void ty_rssi_base_test_start(void); 19 | extern void ty_rssi_base_test_stop(void); 20 | extern void ty_rssi_base_test_update_rssi(u8 rssi); 21 | extern s8 ty_rssi_base_test_get_rssi_avg(int *rssi); 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /includes/components/ty_timer_event.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ty_timer_event.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 10 Apr 2019 14:19:07 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _TY_TIMER_EVENT_H 9 | #define _TY_TIMER_EVENT_H 10 | 11 | #include "board.h" 12 | 13 | #define MAX_TY_TIMER_EVENT_NUM 6 14 | 15 | //ret 16 | // < 0 will delete the timer 17 | // = 0 loop 18 | // > 0 reset the interval_us 19 | typedef int (*ty_timer_event_callback_t)(void); 20 | 21 | typedef struct { 22 | ty_timer_event_callback_t cb; 23 | u32 t; 24 | u32 interval; 25 | }ty_timer_event_s; 26 | 27 | // timer table managemnt 28 | typedef struct { 29 | ty_timer_event_s timer[MAX_TY_TIMER_EVENT_NUM]; 30 | u8 num; 31 | }ty_timer_event_array_s; 32 | 33 | 34 | extern void ty_timer_event_init(void); 35 | extern void ty_timer_event_run(void); 36 | 37 | extern int ty_timer_event_add(ty_timer_event_callback_t cb, u32 interval_us); 38 | extern int ty_timer_event_delete(ty_timer_event_callback_t cb); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /includes/components/ty_uart_cmd_server_for_sig_mesh_uart_common_storage.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ty_uart_cmd_server_for_sig_mesh_uart_common_storage.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 03 Aug 2020 21:59:45 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_STORAGE_H 9 | #define _APP_STORAGE_H 10 | 11 | #include "board.h" 12 | 13 | //4K 14 | #define APP_STORAGE_ADRESS 0x7C000 15 | 16 | #define SAVE_UNIT8_SIZE 8 17 | #define SAVE_VALUE_SIZE 7 //SAVE_UNIT8_SIZE-1 18 | #define SAVE_UNIT8_BACKUP_NUM 30 19 | 20 | 21 | 22 | 23 | 24 | 25 | extern int app_storage_init(void); 26 | extern int app_storage_read(u8 offset, u8 *pdata, u8 len); 27 | extern int app_storage_save(u8 offset, u8 *pdata, u8 len); 28 | 29 | 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /libs/libtuya_ble_os.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TuyaInc/tuya_smesh_sdk_tlsr825x_common/744f2ca45d754c0aa5126a44a927d30c22351976/libs/libtuya_ble_os.a -------------------------------------------------------------------------------- /release.txt: -------------------------------------------------------------------------------- 1 | APP_DEMO 1.0 2 | SDK 1.0 3 | 4 | 1)通用对接DEMO,展示基于 sig mesh vendor 通道透传 dps 数据 5 | 2)支持国家码、GPIO测试从云端拉取、RF测试 6 | 3)支持数据收发、mesh 节点互发数据 7 | 4)支持遥控器功能中的本地控制能力(pub_address 申请) 8 | 9 | --------------------------------------------------------------------------------