Hello NXP JN5169 World

I have one idea - to write an alternative firmware for some ZigBee Xiaomi devices. But there is a problem: I have never worked with NXP JN5169 microcontrollers that are used in Xiaomi devices. NXP provides an IDE, several thousand pages of documentation, a $ 650 developer board, and several megabytes of convoluted sample code. But there was no clear step-by-step tutorial on the Internet.





In this article, let's fill the educational gap and try to write a small Hello World for the NXP JN5169 microcontroller. Go.





Motivation

As I said, NXP provides a ready-made development platform for its devices: 





  • BeyondStudio IDE based on Eclipse, which includes several JN5169 plugins to help you develop ZigBee devices





  • SDK , ZigBee





  • , , API Reference, Application Notes





, . , SDK - BeyondStudio make, , , . , , . , , - .





. ZigBee , . , 2 , . Makefile’. MAC , , . , ( , JN-AN-1219-Zigbee-3-0-Controller-and-Switch)





, , . - . , , . - , . , , JN5169.





$650 , - . EBYTE E75-2G4M10S ( ). .





. GPIO . UART. SPI_MISO , 2 . 









, .





Toolchain file

CMake. , . , , .





, BeyondStudio ( ). gcc .





SET(CMAKE_SYSTEM_NAME Generic)

IF(NOT TOOLCHAIN_PREFIX)
     MESSAGE(STATUS "No TOOLCHAIN_PREFIX specified")
ENDIF()

IF (WIN32)
    SET(TOOL_EXECUTABLE_SUFFIX ".exe")
ELSE()
    SET(TOOL_EXECUTABLE_SUFFIX "")
ENDIF()

SET(TARGET_PREFIX "ba-elf")

SET(TOOLCHAIN_BIN_DIR ${TOOLCHAIN_PREFIX}/bin)
SET(TOOLCHAIN_INC_DIR ${TOOLCHAIN_PREFIX}/include)
SET(TOOLCHAIN_LIB_DIR ${TOOLCHAIN_PREFIX}/lib)

SET(CMAKE_C_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_PREFIX}-gcc${TOOL_EXECUTABLE_SUFFIX})
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_PREFIX}-g++${TOOL_EXECUTABLE_SUFFIX})

SET(CMAKE_OBJCOPY ${TOOLCHAIN_BIN_DIR}/${TARGET_PREFIX}-objcopy${TOOL_EXECUTABLE_SUFFIX} CACHE INTERNAL "objcopy tool")
SET(CMAKE_OBJDUMP ${TOOLCHAIN_BIN_DIR}/${TARGET_PREFIX}-objdump${TOOL_EXECUTABLE_SUFFIX} CACHE INTERNAL "objdump tool")
SET(CMAKE_SIZE ${TOOLCHAIN_BIN_DIR}/${TARGET_PREFIX}-size${TOOL_EXECUTABLE_SUFFIX} CACHE INTERNAL "size tool")
SET(CMAKE_DEBUGER ${TOOLCHAIN_BIN_DIR}/${TARGET_PREFIX}-gdb${TOOL_EXECUTABLE_SUFFIX} CACHE INTERNAL "debuger")
SET(CMAKE_CPPFILT ${TOOLCHAIN_BIN_DIR}/${TARGET_PREFIX}-c++filt${TOOL_EXECUTABLE_SUFFIX} CACHE INTERNAL "C++filt")

SET(CMAKE_C_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "c compiler flags debug")
SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "cxx compiler flags debug")
SET(CMAKE_ASM_FLAGS_DEBUG "-g" CACHE INTERNAL "asm compiler flags debug")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE INTERNAL "linker flags debug")
SET(CMAKE_C_FLAGS_RELEASE "-Os -g" CACHE INTERNAL "c compiler flags release")
SET(CMAKE_CXX_FLAGS_RELEASE "-Os -g" CACHE INTERNAL "cxx compiler flags release")
SET(CMAKE_ASM_FLAGS_RELEASE "-g" CACHE INTERNAL "asm compiler flags release")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "" CACHE INTERNAL "linker flags release")

SET(CMAKE_C_FLAGS "" CACHE INTERNAL "c compiler flags")
SET(CMAKE_CXX_FLAGS "" CACHE INTERNAL "cxx compiler flags")
SET(CMAKE_ASM_FLAGS "" CACHE INTERNAL "asm compiler flags")
SET(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "executable linker flags")
SET(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "module linker flags")
SET(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "shared linker flags")

SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_PREFIX} ${EXTRA_FIND_PATH})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

      
      



, . TOOLCHAIN_PREFIX ( C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379 - ), - , objdump, objcopy, GNU . ( - ). 





 





SET(CMAKE_BUILD_TYPE Release)
SET(CMAKE_TOOLCHAIN_FILE JN5169.cmake)

PROJECT(GPSLogger)
CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
ENABLE_LANGUAGE(CXX)

ADD_EXECUTABLE(Test Test.c)

      
      



#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	return EXIT_SUCCESS;
}

      
      



,





D:\Projects\NXP\HelloJN5169World\build>cmake -G "MinGW Makefiles" -DTOOLCHAIN_PREFIX=C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379 ..
-- ======================
-- Toolchain paths
-- TOOLCHAIN_BIN_DIR = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin
-- TOOLCHAIN_INC_DIR = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/include
-- TOOLCHAIN_LIB_DIR = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/lib
-- CMAKE_C_COMPILER = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-gcc.exe
-- CMAKE_CXX_COMPILER = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-g++.exe
-- CMAKE_OBJCOPY = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-objcopy.exe
-- CMAKE_OBJDUMP = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-objdump.exe
-- CMAKE_SIZE = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-size.exe
-- CMAKE_DEBUGER = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-gdb.exe
-- CMAKE_CPPFILT = C:/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-c++filt.exe
-- ======================
-- Compiler flags
-- CMAKE_C_FLAGS =
-- CMAKE_CXX_FLAGS =
-- CMAKE_ASM_FLAGS =
-- CMAKE_EXE_LINKER_FLAGS =
-- CMAKE_MODULE_LINKER_FLAGS =
-- CMAKE_SHARED_LINKER_FLAGS =
-- CMAKE_C_FLAGS_DEBUG = -Og -g
-- CMAKE_CXX_FLAGS_DEBUG = -Og -g
-- CMAKE_ASM_FLAGS_DEBUG = -g
-- CMAKE_EXE_LINKER_FLAGS_DEBUG =
-- CMAKE_C_FLAGS_RELEASE = -Os -g
-- CMAKE_CXX_FLAGS_RELEASE = -Os -g
-- CMAKE_ASM_FLAGS_RELEASE = -g
-- CMAKE_EXE_LINKER_FLAGS_RELEASE =
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Projects/NXP/HelloJN5169World/build



D:\Projects\NXP\HelloJN5169World\build>mingw32-make
[ 50%] Building C object CMakeFiles/Test.dir/Test.c.obj
[100%] Linking C executable Test
[100%] Built target Test


      
      



Hello World . β„–1

. . 





GPIO ( ) SDK. NXP 416- , API (JN-UG-3087 JN516x Integrated Peripherals API User Guide).





. , DIO17.





#include <stdio.h>
#include <stdlib.h>

#include "AppHardwareApi.h"

#define BOARD_LED_BIT               (17)
#define BOARD_LED_PIN               (1UL << BOARD_LED_BIT)
#define BOARD_LED_CTRL_MASK         (BOARD_LED_PIN)


int main(void)
{
	// Initialize hardware
	vAHI_DioSetDirection(0, BOARD_LED_CTRL_MASK);
	vAHI_DioSetOutput(0, BOARD_LED_PIN);

	return EXIT_SUCCESS;
}

      
      



API ,





IF(NOT SDK_PREFIX)
     MESSAGE(FATAL_ERROR "No SDK_PREFIX specified")
ENDIF()


INCLUDE_DIRECTORIES(
	${SDK_PREFIX}/Components/Common/Include
	${SDK_PREFIX}/Components/HardwareAPI/Include
)

LINK_DIRECTORIES(
	${SDK_PREFIX}/Components/Library
)

ADD_DEFINITIONS(
	-DJENNIC_CHIP_NAME=_JN5169
	-DJENNIC_CHIP_FAMILY_NAME=_JN516x
)

ADD_EXECUTABLE(HelloWorld HelloWorld.cpp)
TARGET_LINK_LIBRARIES(HelloWorld
	HardwareApi_JN5169
)

      
      



, , Cmake - SDK_PREFIX, SDK.





elf , ,





FUNCTION(STM32_ADD_HEX_BIN_TARGETS TARGET)
    IF(EXECUTABLE_OUTPUT_PATH)
      SET(FILENAME "${EXECUTABLE_OUTPUT_PATH}/${TARGET}")
    ELSE()
      SET(FILENAME "${TARGET}")
    ENDIF()
    ADD_CUSTOM_TARGET(${TARGET}.hex DEPENDS ${TARGET} COMMAND ${CMAKE_OBJCOPY} -Oihex ${FILENAME} ${FILENAME}.hex)
    ADD_CUSTOM_TARGET(${TARGET}.bin DEPENDS ${TARGET} COMMAND ${CMAKE_OBJCOPY} -Obinary ${FILENAME} ${FILENAME}.bin)
ENDFUNCTION()

      
      



. . , BeyondStudio. ( BOOT, RESET), Devices->Program Device. , -





Hello World . β„–2

BeyondStudio . . , .





BeyondStudio ( )
Compiling /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/BDB/Source/FindAndBind/bdb_fb_initiator.c ...
/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-gcc -c -o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/bdb_fb_initiator.o -DCONFIG_MANUFACTURER_CODE=0x1037 -DCONFIG_APP_SW_VERSION=7                                                                      -DCONFIG_HW_VERSION=1                             -DCONFIG_MANUFACTURER_NAME=\"NXP\" -DCONFIG_MODEL_ID=\"DIMMER_SW\"                               -DCONFIG_DATE_CODE=\"10-31-2014\"               -DSINGLE_CHANNEL=0 -DKEEP_ALIVETIME=1 -DSLEEP_ENABLE -DDEEP_SLEEP_ENABLE -DDR1199 -DDimmerSwitch -DBUTTON_MAP_DR1199 -DSLEEPY_ZED -DEZ_MODE_INITIATOR -DEZ_ENABLE_GROUP -DDBG_ENABLE -DDEBUG_APP_BUTTON -DDEBUG_APP -DDEBUG_START_UP -DDEBUG_SWITCH_STATE -DDEBUG_SWITCH_TASK -DDEBUG_SWITCH_NODE -DDimmerSwitch -DPDM_USER_SUPPLIED_ID -DJN516x=5160 -DJN5169=5169 -DJENNIC_CHIP_NAME=_JN5169 -DJENNIC_CHIP_FAMILY_NAME=_JN516x -march=ba2 -mcpu=jn51xx -mredzone-size=4 -mbranch-cost=3 -fomit-frame-pointer -Os -fshort-enums -Wall  -Wpacked -Wcast-align -fdata-sections -ffunction-sections -DWATCHDOG_ENABLED -DJENNIC_HW_BBC_RXINCCA=1 -DJENNIC_HW_BBC_DMA=1 -DJENNIC_HW_BBC_ISA=0 -DJENNIC_SW_EXTERNAL_FLASH=0 -DJN516X_DMA_UART_BACKWARDS_COMPATIBLE_API=1 -DUART_BACKWARDS_COMPATIBLE_API=1 -DRXPOWERADJUST_SUPPORT -DJENNIC_CHIP=JN5169 -DJENNIC_CHIP_JN5169 -DJENNIC_CHIP_FAMILY=JN516x -DJENNIC_CHIP_FAMILY_JN516x -DJENNIC_STACK_ZCL -DJENNIC_MAC_MiniMacShim -Wall -Wunreachable-code -DEMBEDDED -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Platform/Common/Include -DJENNIC_PCB=DEVKIT4 -DJENNIC_PCB_DEVKIT4 -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Platform/DK4/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/Common/Include -DPDM_USER_SUPPLIED_ID -DPDM_NO_RTOS -DPDM_EEPROM -DDBG_ENABLE -DZPS_APL_OPT_SINGLE_INSTANCE -DOTA_NO_CERTIFICATE -DPLME_SAP -DZBPRO_DEVICE_TYPE_ZED -DBDB_SUPPORT_NWK_STEERING -DBDB_SUPPORT_FIND_AND_BIND_INITIATOR -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/Common_Switch/Source -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/Common_Switch/Source/.. -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Source -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/Common/Source -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZigbeeCommon/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCIF/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/Xcv/Include/ -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/Recal/Include/ -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/MicroSpecific/Include  -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/HardwareAPI/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/AppApi/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/MAC/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/MiniMac/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/MMAC/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/HardwareAPI/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/Aes/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/DBG/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/Mac/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/MicroSpecific/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/MiniMAC/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/MMAC/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/TimerServer/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/Random/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZigbeeCommon/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZPSMAC_Mini_SOC/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/PWRM/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZPSTSV/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/AES_SW/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/PDUM/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZPSAPL/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/Random/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/PDM_EEPROM_NO_RTOS/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/DBG/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZPSNWK_ZED/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/PDM/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZPSMAC/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZPSNWK/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZigbeeCommon/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCIF/Source -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCIF/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/General/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/General/Source -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/MeasurementAndSensing/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/Lighting/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/HVAC/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/Closures/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/SecurityAndSafety/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/SmartEnergy/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/OTA/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/Commissioning/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/ApplianceManagement/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/GreenPower/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Clusters/Private/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Devices/ZHA/Generic/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/ZCL/Devices/ZLO/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/BDB/Include -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/BDB/Source/Common -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/BDB/Source/NwkSteering -I/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/BDB/Source/FindAndBind /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/BDB/Source/FindAndBind/bdb_fb_initiator.c -MD -MF /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/bdb_fb_initiator.d -MP

Linking /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DimmerSwitch_JN5169_DR1199.elf ...
/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-gcc -Wl,--gc-sections -Wl,-u_AppColdStart -Wl,-u_AppWarmStart -march=ba2 -mcpu=jn51xx -mredzone-size=4 -mbranch-cost=3 -fomit-frame-pointer -Os -fshort-enums -nostartfiles -L/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Chip/JN5169/Build -L/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Chip/JN5169/Library -L/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Platform/DK4/Library -L/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Components/Library -Wl,--gc-sections -L/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Stack/ZBPro/Build -Wl,--defsym=__stack_size=5000 -Wl,--defsym,__minimum_heap_size=2000 -TAppBuildZBPro.ld -L /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/JN-SW-4170/Stack/ZCL/Build/ -o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DimmerSwitch_JN5169_DR1199.elf -Wl,--start-group /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/irq_JN516x.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/portasm_JN516x.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/port_JN516x.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/pdum_gen.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/pdum_apdu.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zps_gen.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_pdm.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_main.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_start_switch.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/App_DimmerSwitch.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_zlo_switch_node.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_zcl_switch_task.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_buttons.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_switch_state_machine.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_pdm_convert.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ZQueue.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ZTimer.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/app_zps_link_keys.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/Alarms.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/AlarmsClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/AlarmsCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/AlarmsServerCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/AlarmsTableManager.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/AnalogInputBasic.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/AnalogOutputBasic.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/Basic.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/BasicClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/BasicCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/BinaryInputBasic.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/BinaryOutputBasic.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DeviceTemperatureConfiguration.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/Diagnostics.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/Groups.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/GroupsClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/GroupsCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/GroupsServerCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/GroupsTableManager.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/Identify.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/IdentifyClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/IdentifyCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/IdentifyServerCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/LevelControl.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/LevelControlClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/LevelControlCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/MultistateInputBasic.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/MultistateOutputBasic.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/OOSC.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/OnOff.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/OnOffCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/OnOffCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PollControl.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PollControlClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PollControlCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PollControlServerCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PowerConfiguration.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PowerProfile.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PowerProfileClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PowerProfileCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/PowerProfileServerCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/Scenes.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ScenesClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ScenesClusterManagement.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ScenesCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ScenesServerCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ScenesTableManager.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/TC.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/Time.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/base_device.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/mains_power_outlet.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/on_off_output.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/plug_control.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/remote_control.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/simple_sensor.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/BallastConfiguration.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ColourControl.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ColourControlClientCommands.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ColourControlCommandHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/ColourControlConversions.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/colour_controller.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/colour_dimmable_light.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/colour_dimmer_switch.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/colour_scene_controller.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/colour_temperature_light.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/commission_endpoint.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/control_bridge.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/dimmable_ballast.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/dimmable_light.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/dimmable_plug.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/dimmer_switch.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/extended_colour_light.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/light_level_sensor.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/light_sensor.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/non_colour_controller.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/non_colour_scene_controller.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/occupancy_sensor.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/on_off_ballast.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/on_off_light.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/on_off_light_switch.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/on_off_plug.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/on_off_sensor.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/privateCluster.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/dlist.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_CustomCommandReceive.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_CustomCommandSend.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_PDUbufferReadWrite.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_PDUbufferReadWriteString.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_WriteAttributesRequestHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_WriteAttributesRequestSend.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_WriteAttributesResponseHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_attribute.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_buffer.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_clusterCommand.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_command.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_common.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_configureReportingCommandHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_configureReportingCommandSend.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_configureReportingResponseHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_defaultResponse.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverAttributesExtendedRequestHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverAttributesExtendedRequestSend.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverAttributesExtendedResponseHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverAttributesRequestHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverAttributesRequestSend.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverAttributesResponseHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverCommandsRequestHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverCommandsRequestSend.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_discoverCommandsResponseHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_event.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_heap.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_library_options.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_readAttributesRequestHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_readAttributesRequestSend.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_readAttributesResponseHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_readReportingConfigurationCommandHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_readReportingConfigurationCommandSend.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_readReportingConfigurationResponseHandle.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_reportManager.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_reportMaths.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_reportScheduler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_reportStringHandling.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_reportStructure.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_search.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_timer.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/zcl_transmit.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/bdb_fr.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/bdb_start.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/bdb_state_machine.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/appZpsBeaconHandler.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/appZdpExtraction.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/bdb_ns.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/bdb_fb_common.o /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/bdb_fb_initiator.o -lZPSMAC_Mini_SOC_JN516x -lPWRM_JN516x -lZPSTSV_JN516x -lAES_SW_JN516x -lPDUM_JN516x -lZPSAPL_JN516x -lRandom_JN516x -lPDM_EEPROM_NO_RTOS_JN516x -lDBG_JN516x -lZPSNWK_ZED_JN516x -lRecal_JN516x -lJPT_JN5169 -lMiniMac_JN5169 -lMiniMacShim_JN516x -lMMAC_JN5169 -lJPT_JN5169 -lAes_JN516x -lHardwareApi_JN5169 -lMicroSpecific_JN516x -lBoot_JN516x -lBoardLib_JN516x -lm -Wl,--end-group -Wl,-Map,/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DimmerSwitch_JN5169_DR1199.map
/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-size /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DimmerSwitch_JN5169_DR1199.elf
   text    data     bss     dec     hex filename
 139470    1624   23149  164243   28193 d:/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DimmerSwitch_JN5169_DR1199.elf
date +%c >> /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/Doc/size.txt
/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-size /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DimmerSwitch_JN5169_DR1199.elf >> /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/Doc/size.txt
Generating binary ...
/d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-objcopy -j .version -j .bir -j .flashheader -j .vsr_table -j .vsr_handlers  -j .rodata -j .text -j .data -j .bss -j .heap -j .stack -S -O binary /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DimmerSwitch_JN5169_DR1199.elf /d/Projects/NXP/JN5169-for-xiaomi-wireless-switch/Application/JN-AN-1219-Zigbee-3-0-Controller-and-Switch/DimmerSwitch/Build/DimmerSwitch_JN5169_DR1199.bin
      
      



, ( ), , , , .





SET(CMAKE_C_FLAGS "-march=ba2 -mcpu=jn51xx -mredzone-size=4 -mbranch-cost=3 -fomit-frame-pointer -fshort-enums -Wall -Wpacked -Wcast-align -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")
SET(CMAKE_CXX_FLAGS "-march=ba2 -mcpu=jn51xx -mredzone-size=4 -mbranch-cost=3 -fomit-frame-pointer -fshort-enums -Wall -Wpacked -Wcast-align -fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")
SET(CMAKE_ASM_FLAGS "-march=ba2 -mcpu=jn51xx -mredzone-size=4 -mbranch-cost=3 -fomit-frame-pointer -fshort-enums -Wall -Wpacked -Wcast-align -fdata-sections -ffunction-sections" CACHE INTERNAL "asm compiler flags")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections -Wl,-u_AppColdStart -Wl,-u_AppWarmStart -march=ba2 -mcpu=jn51xx -mredzone-size=4 -mbranch-cost=3 -fomit-frame-pointer -Os -fshort-enums -nostartfiles -Wl,--gc-sections -Wl,--defsym=__stack_size=5000 -Wl,--defsym,__minimum_heap_size=2000 " CACHE INTERNAL "executable linker flags")
      
      



objcopy - ( , )





ADD_CUSTOM_TARGET(${TARGET}.bin DEPENDS ${TARGET} COMMAND ${CMAKE_OBJCOPY} -j .version -j .bir -j .flashheader -j .vsr_table -j .vsr_handlers  -j .rodata -j .text -j .data -j .bss -j .heap -j .stack -S -O binary ${FILENAME} ${FILENAME}.bin)
      
      



. .





Hello World . β„–3

-TAppBuildZBPro.ld. , ! 





, , Hello World, . . - , . . , , , , , . 





, , : , , . , , .





, -TAppBuildZBPro.ld CMAKE_EXE_LINKER_FLAGS





c:/nxp/bstudio_nxp/sdk/tools/ba-elf-ba2-r36379/bin/../lib/gcc/ba-elf/4.7.4/../../../../ba-elf/bin/ld.exe: invalid data statement
collect2.exe: error: ld returned 1 exit status
      
      



, , .





, . , . , , . , . .





. , main() - CPU, , . , _start() . NXP 2 AppColdStart AppWarmStart, libPWRM_JN516x.a ( SDK ).





pwrm_cold_start.c:(.text.AppColdStart+0xc): undefined reference to `vAppRegisterPWRMCallbacks'
pwrm_cold_start.c:(.text.AppColdStart+0xc): relocation truncated to fit: R_BA_18_PCREL against undefined symbol `vAppRegisterPWRMCallbacks'
pwrm_cold_start.c:(.text.AppColdStart+0x1b): undefined reference to `vAppMain'
pwrm_cold_start.c:(.text.AppColdStart+0x1b): relocation truncated to fit: R_BA_10_PCREL against undefined symbol `vAppMain'
      
      



JN-UG-3116 JN51xx Core Utilities User Guide. , libPWRM_JN516x.a , main() vAppMain(). .





PUBLIC void vAppMain(void)
{
	int i;

	// Initialize hardware
	vAHI_DioSetDirection(0, BOARD_LED_CTRL_MASK);


	while(1)
	{
		vAHI_DioSetOutput(0, BOARD_LED_PIN);

		for(i=0; i<200000; i++)
		        vAHI_DioSetOutput(0, BOARD_LED_PIN);

		vAHI_DioSetOutput(BOARD_LED_PIN, 0);

		for(i=0; i<1000000; i++)
		        vAHI_DioSetOutput(BOARD_LED_PIN, 0);
	}
}

      
      



vAppMain() . , vAHI_DioSetOutput() . for, , ( ) .





, vAHI_DioSetOutput , (, ) ( ). , ).





vAppRegisterPWRMCallbacks() - /. , .





, .





Hello Debug UART

, . , ? . UART . UART, . USB-UART .





UART0 115200 ( , - vAppMain ). DBG_vPrintf .





PUBLIC void vAppMain(void)
{
    int i;
    int iteration = 0;

    // Initialize UART
    DBG_vUartInit(DBG_E_UART_0, DBG_E_UART_BAUD_RATE_115200);

    // Initialize hardware
    vAHI_DioSetDirection(0, BOARD_LED_CTRL_MASK);


    while(1)
    {
        DBG_vPrintf(TRUE, "Blink iteration %d\n", iteration++);

        vAHI_DioSetOutput(0, BOARD_LED_PIN);

        for(i=0; i<1000000; i++)
            vAHI_DioSetOutput(0, BOARD_LED_PIN);

        vAHI_DioSetOutput(BOARD_LED_PIN, 0);

        for(i=0; i<1000000; i++)
            vAHI_DioSetOutput(BOARD_LED_PIN, 0);
    }
}
      
      



DBG_vPrintf / , . .





.... . dbg.h , DBG_ENABLE. , .





TARGET_LINK_LIBRARIES(HelloWorld
            -Wl,--start-group

            PWRM_JN516x
            HardwareApi_JN5169
            DBG_JN516x
            Boot_JN516x

            -Wl,--end-group
)

      
      



, . , , ( ). . DBG_JN516x UART HardwareApi_JN5169, , unresolved externals UART. -Wl,--start-group/-Wl,--end-group , , . .





, .





Hello Watchdog

, 7?





. 16 . vAHI_WatchdogRestart().





, bAHI_WatchdogResetEvent() - , - .





PUBLIC void vAppMain(void)
{
    int i;
    int iteration = 0;
    int debugEnabled = 1;

    // Initialize UART
    DBG_vUartInit(DBG_E_UART_0, DBG_E_UART_BAUD_RATE_115200);

    // Initialize hardware
    vAHI_DioSetDirection(0, BOARD_LED_CTRL_MASK);

    if (bAHI_WatchdogResetEvent())
    {
        DBG_vPrintf(TRUE, "APP: Watchdog timer has reset device!\n");
        DBG_vDumpStack();
    }   

    while(1)
    {
        DBG_vPrintf(debugEnabled, "Blink iteration %d\n", iteration++);

        vAHI_DioSetOutput(0, BOARD_LED_PIN);

        for(i=0; i<1000000; i++)
            vAHI_DioSetOutput(0, BOARD_LED_PIN);

        vAHI_DioSetOutput(BOARD_LED_PIN, 0);

        for(i=0; i<1000000; i++)
           vAHI_DioSetOutput(BOARD_LED_PIN, 0);

        vAHI_WatchdogRestart();
    }
}

      
      



Hello software timers

- , , SPI, , JN5169. . , NXP. .





ZigBee NXP, JN-UG-3113 ZigBee 3.0 Stack User Guide. .





ZTIMER_tsTimer timers[1];
uint8 blinkTimerHandle;

PUBLIC void vAppMain(void)
{
	// Initialize UART
	DBG_vUartInit(DBG_E_UART_0, DBG_E_UART_BAUD_RATE_115200);

	// Initialize hardware
	vAHI_DioSetDirection(0, BOARD_LED_CTRL_MASK);

	// Init and start timers
	ZTIMER_eInit(timers, sizeof(timers) / sizeof(ZTIMER_tsTimer));
	ZTIMER_eOpen(&blinkTimerHandle, blinkFunc, NULL, ZTIMER_FLAG_PREVENT_SLEEP);
	ZTIMER_eStart(blinkTimerHandle, ZTIMER_TIME_MSEC(1000));

	while(1)
	{
		ZTIMER_vTask();

		vAHI_WatchdogRestart();
	}
}


      
      



vAppMain() , , . , timers. ZTIMER_vTask(), . 





. , , .





PUBLIC void blinkFunc(void *pvParam)
{
	static int iteration = 0;
	DBG_vPrintf(TRUE, "Blink iteration %d\n", iteration++);
	
	uint32 currentState = u32AHI_DioReadInput();
	vAHI_DioSetOutput(currentState^BOARD_LED_PIN, currentState&BOARD_LED_PIN);
}

      
      



, , vAHI_DioSetOutput(), .





ZigBee , . CMakeLists.txt .





################################
# Common settings

ADD_DEFINITIONS(
	-DJENNIC_CHIP_NAME=_JN5169
	-DJENNIC_CHIP_FAMILY_NAME=_JN516x
	-DJENNIC_CHIP_FAMILY_JN516x
	-DJENNIC_CHIP_FAMILY=JN516x
	-DJN516x=5160
	-DDBG_ENABLE
	-DEMBEDDED
)


################################
# Zigbee Library

SET(ZIGBEE_SRC
	${SDK_PREFIX}/Components/ZigbeeCommon/Source/ZTimer.c
)
ADD_LIBRARY(ZigBee STATIC ${ZIGBEE_SRC})
TARGET_INCLUDE_DIRECTORIES(ZigBee PRIVATE
	${SDK_PREFIX}/Components/PWRM/Include
)
      
      



, JN5169 - . , , .





, ... , . ( ), , tick timer’ ( JN5169). , - . .





, irq_JN516x.S, . ? , . 





: , - PIC_ChannelPriorities, TARGET_INITIALISE(). , , vAppMain() . portasm_JN516x.S, TARGET_INITIALIZE() .





, vAppMain()





        // Initialize the hardware
        TARGET_INITIALISE();
        SET_IPL(0);
        portENABLE_INTERRUPTS();

      
      



, community.nxp.com irq_JN516x.S - - . . , JN5179. .





. . ? ZTIMER_vTask() , - , . , ZigBee , . .





PUBLIC void blinkFunc(void *pvParam)
{
	static int iteration = 0;
	DBG_vPrintf(TRUE, "Blink iteration %d\n", iteration++);

	uint32 currentState = u32AHI_DioReadInput();
	vAHI_DioSetOutput(currentState^BOARD_LED_PIN, currentState&BOARD_LED_PIN);

	ZTIMER_eStart(blinkTimerHandle, ZTIMER_TIME_MSEC(1000));
}

      
      



Hello queues

( ) . . , , - / . .





2 - , - . vAppMain(). , pull-up , . 





- . 3 .






	// Initialize hardware
	vAHI_DioSetDirection(BOARD_BTN_PIN, BOARD_LED_PIN);
	vAHI_DioSetPullup(BOARD_BTN_PIN, 0);

	// Init and start timers
	ZTIMER_eInit(timers, sizeof(timers) / sizeof(ZTIMER_tsTimer));
	ZTIMER_eOpen(&blinkTimerHandle, blinkFunc, NULL, ZTIMER_FLAG_PREVENT_SLEEP);
	ZTIMER_eStart(blinkTimerHandle, ZTIMER_TIME_MSEC(1000));
	ZTIMER_eOpen(&buttonScanTimerHandle, buttonScanFunc, NULL, ZTIMER_FLAG_PREVENT_SLEEP);
	ZTIMER_eStart(buttonScanTimerHandle, ZTIMER_TIME_MSEC(10));

	// Initialize queue
	ZQ_vQueueCreate(&queueHandle, 3, sizeof(ButtonPressType), (uint8*)queue);

      
      



10, . ( 50) , . (>2c) , .





typedef enum
{
	BUTTON_SHORT_PRESS,
	BUTTON_LONG_PRESS
} ButtonPressType;


PUBLIC void buttonScanFunc(void *pvParam)
{
	static int duration = 0;

	uint32 input = u32AHI_DioReadInput();
	bool btnState = (input & BOARD_BTN_PIN) == 0;

	if(btnState)
	{
		duration++;
	}
	else
	{
		// detect long press
		if(duration > 200)
		{
			DBG_vPrintf(TRUE, "Button released. Long press detected\n");
			ButtonPressType value = BUTTON_LONG_PRESS;
			ZQ_bQueueSend(&queueHandle, (uint8*)&value);
		}

		// detect short press
		else if(duration > 5)
		{
			DBG_vPrintf(TRUE, "Button released. Short press detected\n");
			ButtonPressType value = BUTTON_SHORT_PRESS;
			ZQ_bQueueSend(&queueHandle, &value);
		}

		duration = 0;
	}

	ZTIMER_eStart(buttonScanTimerHandle, ZTIMER_TIME_MSEC(10));
}

      
      



. - /, /. , .





PUBLIC void blinkFunc(void *pvParam)
{
	static uint8 fastBlink = TRUE;
	static uint8 enabled = TRUE;

	ButtonPressType value;	
	if(ZQ_bQueueReceive(&queueHandle, (uint8*)&value))
	{
		if(value == BUTTON_SHORT_PRESS)
			fastBlink = fastBlink ? FALSE : TRUE;

		if(value == BUTTON_LONG_PRESS)
			enabled = enabled ? FALSE : TRUE;
	}

	if(enabled)
	{
		uint32 currentState = u32AHI_DioReadInput();
		vAHI_DioSetOutput(currentState^BOARD_LED_PIN, currentState&BOARD_LED_PIN);
	}

	ZTIMER_eStart(blinkTimerHandle, fastBlink? ZTIMER_TIME_MSEC(200) : ZTIMER_TIME_MSEC(1000));
}

      
      



, .





Hello DIO Interrupts

, , , . . , .





.





	// Initialize hardware
	vAHI_DioSetDirection(BOARD_BTN_PIN, BOARD_LED_PIN);
	vAHI_DioSetPullup(BOARD_BTN_PIN, 0);
	vAHI_DioInterruptEdge(0, BOARD_BTN_PIN);
	vAHI_DioInterruptEnable(BOARD_BTN_PIN, 0);

	// Init and start timers
	ZTIMER_eInit(timers, sizeof(timers) / sizeof(ZTIMER_tsTimer));
	ZTIMER_eOpen(&blinkTimerHandle, blinkFunc, NULL, ZTIMER_FLAG_PREVENT_SLEEP);
	ZTIMER_eStart(blinkTimerHandle, ZTIMER_TIME_MSEC(1000));
	ZTIMER_eOpen(&buttonScanTimerHandle, buttonScanFunc, NULL, ZTIMER_FLAG_PREVENT_SLEEP);
	//ZTIMER_eStart(buttonScanTimerHandle, ZTIMER_TIME_MSEC(10));

      
      



vAHI_DioInterruptEdge() vAHI_DioInterruptEnable(). , ( ZTIMER_eOpen() )





ATMega STM32, JN5169 - vISR_SystemController(). , , , , - . .





PUBLIC void vISR_SystemController(void)
{
    DBG_vPrintf(TRUE, "In vISR_SystemController\n");

    if(u32AHI_DioInterruptStatus() & BOARD_BTN_PIN)
    {
        DBG_vPrintf(TRUE, "Button interrupt\n");

        ZTIMER_eStart(buttonScanTimerHandle, ZTIMER_TIME_MSEC(10));
    }
}

      
      



DIO Interrupt. . , .





. , .





PUBLIC void buttonScanFunc(void *pvParam)
{
	static int duration = 0;

	uint32 input = u32AHI_DioReadInput();
	bool btnState = (input & BOARD_BTN_PIN) == 0;

	if(btnState)
	{
		duration++;
		DBG_vPrintf(TRUE, "Button still pressed for %d ticks\n", duration);
		ZTIMER_eStart(buttonScanTimerHandle, ZTIMER_TIME_MSEC(10));
	}
	else
	{
		// detect long press
		if(duration > 200)
		{
			DBG_vPrintf(TRUE, "Button released. Long press detected\n");
			ButtonPressType value = BUTTON_LONG_PRESS;
			ZQ_bQueueSend(&queueHandle, (uint8*)&value);
		}

		// detect short press
		else if(duration > 10)
		{
			DBG_vPrintf(TRUE, "Button released. Short press detected\n");
			ButtonPressType value = BUTTON_SHORT_PRESS;
			ZQ_bQueueSend(&queueHandle, &value);
		}

		duration = 0;
	}
}

      
      



Tick Timer’, vISR_SystemController() irq_JN516x.S.





? , DIO Interrupt, - ( ) .





Hello sleep/wake

, . . , , . - :)





, / PWRM ( Power Management). 2 , , .





static PWRM_DECLARE_CALLBACK_DESCRIPTOR(PreSleep);
static PWRM_DECLARE_CALLBACK_DESCRIPTOR(Wakeup);

PWRM_CALLBACK(PreSleep)
{
    DBG_vPrintf(TRUE, "Going to sleep..\n\n");
    DBG_vUartFlush();

    ZTIMER_vSleep();

    // Disable UART (if enabled)
    vAHI_UartDisable(E_AHI_UART_0);

    // clear interrupts
    u32AHI_DioWakeStatus();                         

    // Set the wake condition on falling edge of the button pin
    vAHI_DioWakeEdge(0, BOARD_BTN_PIN);
    vAHI_DioWakeEnable(BOARD_BTN_PIN, 0);
}

PWRM_CALLBACK(Wakeup)
{
    // Stabilise the oscillator
    while (bAHI_GetClkSource() == TRUE);

    // Now we are running on the XTAL, optimise the flash memory wait states
    vAHI_OptimiseWaitStates();

    // Re-initialize Debug UART
    DBG_vUartInit(DBG_E_UART_0, DBG_E_UART_BAUD_RATE_115200);

    DBG_vPrintf(TRUE, "\nWaking..\n");
    DBG_vUartFlush();

    // Re-initialize hardware and interrupts
    TARGET_INITIALISE();
    SET_IPL(0);
    portENABLE_INTERRUPTS();

    // Wake the timers
    ZTIMER_vWake();
}


void vAppRegisterPWRMCallbacks(void)
{
    PWRM_vRegisterPreSleepCallback(PreSleep);
    PWRM_vRegisterWakeupCallback(Wakeup);	
}

      
      



PreSleep() - , UART , , GPIO. , .





Wakeup() - , UART, , . vAppMain(), .





( ).





uint8 enabled = TRUE;

PUBLIC void blinkFunc(void *pvParam)
{
	static uint8 fastBlink = TRUE;

	ButtonPressType value;	
	if(ZQ_bQueueReceive(&queueHandle, (uint8*)&value))
	{
		DBG_vPrintf(TRUE, "Processing message in blink task\n");

		if(value == BUTTON_SHORT_PRESS)
			fastBlink = fastBlink ? FALSE : TRUE;

		if(value == BUTTON_LONG_PRESS)
		{
			DBG_vPrintf(TRUE, "Stop Blinking\n");
			vAHI_DioSetOutput(BOARD_LED_PIN, 0);
			enabled = FALSE;
		}
	}

	if(enabled)
	{
		uint32 currentState = u32AHI_DioReadInput();
		vAHI_DioSetOutput(currentState^BOARD_LED_PIN, currentState&BOARD_LED_PIN);
	}

	ZTIMER_eStart(blinkTimerHandle, fastBlink? ZTIMER_TIME_MSEC(200) : ZTIMER_TIME_MSEC(1000));
}

      
      



enabled , .. . .





. , , , .





PUBLIC void buttonScanFunc(void *pvParam)
{
	static int duration = 0;

	uint32 input = u32AHI_DioReadInput();
	bool btnState = (input & BOARD_BTN_PIN) == 0;

	if(btnState)
	{
		duration++;
		DBG_vPrintf(TRUE, "Button still pressed for %d ticks\n", duration);
	}
	else
	{
		// detect long press
		if(duration > 200)
		{
			DBG_vPrintf(TRUE, "Button released. Long press detected\n");
			ButtonPressType value = BUTTON_LONG_PRESS;
			ZQ_bQueueSend(&queueHandle, (uint8*)&value);
		}

		// detect short press
		else if(duration > 5)
		{
			DBG_vPrintf(TRUE, "Button released. Short press detected\n");
			ButtonPressType value = BUTTON_SHORT_PRESS;
			ZQ_bQueueSend(&queueHandle, &value);
		}

		duration = 0;
	}

	ZTIMER_eStart(buttonScanTimerHandle, ZTIMER_TIME_MSEC(10));
}

      
      



, , ? vAppMain(). , ALLOW_SLEEP. PREVENT_SLEEP, , , . . , . , , .





	// Init and start timers
	ZTIMER_eInit(timers, sizeof(timers) / sizeof(ZTIMER_tsTimer));
	ZTIMER_eOpen(&blinkTimerHandle, blinkFunc, NULL, ZTIMER_FLAG_ALLOW_SLEEP);
	ZTIMER_eStart(blinkTimerHandle, ZTIMER_TIME_MSEC(1000));
	ZTIMER_eOpen(&buttonScanTimerHandle, buttonScanFunc, NULL, ZTIMER_FLAG_ALLOW_SLEEP);
	ZTIMER_eStart(buttonScanTimerHandle, ZTIMER_TIME_MSEC(10));

      
      







PRIVATE uint8 keepAliveTime = 10;
PRIVATE pwrm_tsWakeTimerEvent wakeStruct;

PUBLIC void vAppMain(void)
{
...

	// Let the device go to sleep if there is nothing to do
	PWRM_vInit(E_AHI_SLEEP_OSCON_RAMON);

	while(1)
	{
		ZTIMER_vTask();

		vAHI_WatchdogRestart();

		if(enabled == FALSE)
		{
			DBG_vPrintf(TRUE, "Scheduling wake task\n");
			PWRM_eScheduleActivity(&wakeStruct, keepAliveTime * 32000, wakeCallBack);
		}

		PWRM_vManagePower();
	}

      
      



( ) PWRM_vInit(). - E_AHI_SLEEP_OSCON_RAMON, wake up timer , . - enabled. , . wake up , , - , ZigBee.





PWRM_vManagePower(). . . . - ( PREVENT_SLEEP). - , PWRM_eScheduleActivity(), enabled.





, - ,





PUBLIC void vISR_SystemController(void)
{
    // clear pending DIO changed bits by reading register
    uint8 u8WakeInt = u8AHI_WakeTimerFiredStatus();
    uint32 u32IOStatus = u32AHI_DioInterruptStatus();

    DBG_vPrintf(TRUE, "In vISR_SystemController\n");

    if(u32IOStatus & BOARD_BTN_PIN)
    {
        DBG_vPrintf(TRUE, "Button interrupt\n");
        enabled = TRUE;
        PWRM_vWakeInterruptCallback();
    }

    if(u8WakeInt & E_AHI_WAKE_TIMER_MASK_1)
    {
        /* wake timer interrupt got us here */
        DBG_vPrintf(TRUE, "APP: Wake Timer 1 Interrupt\n");

        PWRM_vWakeInterruptCallback();
    }
}

      
      



2 , - , . enabled, . . PreSleep() Wakeup(), , PWRM_eScheduleActivity().





PUBLIC void wakeCallBack(void)
{
    DBG_vPrintf(TRUE, "wakeCallBack()\n");
}

      
      



, , , , .





Hello Deep Sleep

- wake up , . , . .





PUBLIC void vAppMain(void)
{
...
	// Let the device go to sleep if there is nothing to do
	PWRM_vInit(E_AHI_SLEEP_DEEP);

	while(1)
	{
		ZTIMER_vTask();

		vAHI_WatchdogRestart();

		if(enabled == FALSE)
		{
			DBG_vPrintf(TRUE, "Scheduling sleep\n");
			PWRM_vManagePower();
		}
	}
}

      
      



wake up vISR_SystemController(), .





. , , . , ( ) - vAppMain() Wakeup(). , , . , .





EEPROM. 2





  1. EEPROM - EEPROM





  2. Persistent Data Manager (PDM) - key-value storage EEPROM





, .. ZigBee , PDM, . 





. .





#define PDM_ID_BLINK_MODE   	    0x2
#define BLINK_MODE_SLOW		    0
#define BLINK_MODE_FAST		    1

uint8 blinkMode = BLINK_MODE_SLOW;

void storeBlinkMode(uint8 mode)
{
	blinkMode = mode;
	PDM_teStatus status = PDM_eSaveRecordData(PDM_ID_BLINK_MODE, &blinkMode, sizeof(blinkMode));
	DBG_vPrintf(TRUE, "Storing blink mode. Status %d, value %d\n", status, blinkMode);	
}

void restoreBlinkMode()
{
	uint16 readBytes;
	PDM_teStatus status = PDM_eReadDataFromRecord(PDM_ID_BLINK_MODE, &blinkMode, sizeof(blinkMode), &readBytes);

	DBG_vPrintf(TRUE, "Reading blink mode. Status %d, size %d, value %d\n", status, readBytes, blinkMode);	
}

      
      



blinkFunc(), ( , blinkFunc() ). vAppMain() - . , PDM .





PUBLIC void vAppMain(void)
{
...
	// Restore blink mode from EEPROM
	PDM_eInitialise(0);
	restoreBlinkMode();

      
      



JN5169 , . , () . 





HelloWorld - . ZigBee. , , .





, BeyondStudio. BeyondStudio. , Eclipse/BeyondStudio , CMake.





.









Documentation used:





https://www.nxp.com/docs/en/user-guide/JN-UG-3113.pdf





https://www.nxp.com/docs/en/user-guide/JN-UG-3116.pdf





https://www.nxp.com/docs/en/user-guide/JN-UG-3087.pdf





https://www.rcscomponents.kiev.ua/datasheets/e75-2g4m10s_usermanual_en_v1_1.pdf








All Articles