⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nullnode.c

📁 关于zigbee厂家jennic的zigbee通信模块JN5139的一些示例程序。
💻 C
字号:
/****************************************************************************
 *
 * MODULE:             Null Node
 * COMPONENT:          NullNode.c,v
 *
 * VERSION:
 *
 * REVISION:           1.8
 *
 * DATED:              2007/01/03 15:18:25
 *
 * STATUS:             Exp
 *
 * AUTHOR:             GPfef
 *
 * DESCRIPTION:
 *
 *
 * LAST MODIFIED BY:   gpfef
 *                     $Modtime: $
 *
 ****************************************************************************
 *
 * This software is owned by Jennic and/or its supplier and is protected
 * under applicable copyright laws. All rights are reserved. We grant You,
 * and any third parties, a license to use this software solely and
 * exclusively on Jennic products. You, and any third parties must reproduce
 * the copyright and warranty notice and any other legend of ownership on each
 * copy or partial copy of the software.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS". JENNIC MAKES NO WARRANTIES, WHETHER
 * EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
 * ACCURACY OR LACK OF NEGLIGENCE. JENNIC SHALL NOT, IN ANY CIRCUMSTANCES,
 * BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, SPECIAL,
 * INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER.
 *
 * Copyright Jennic Ltd 2005, 2006. All rights reserved
 *
 ****************************************************************************/

/****************************************************************************/
/***        Include files                                                 ***/
/****************************************************************************/
#include "jendefs.h"
#include <AppHardwareApi.h>
#include <string.h>
#include "gdb.h"
#include "JZ_Api.h"
#include "af.h"
#include "aps.h"
#include "nwk.h"
#include "af.h"
#include "LedControl.h"

/****************************************************************************/
/***        Macro Definitions                                             ***/
/****************************************************************************/

/****************************************************************************/
/***        Type Definitions                                              ***/
/****************************************************************************/

/****************************************************************************/
/***        Local Function Prototypes                                     ***/
/****************************************************************************/
PRIVATE void NullDeviceInit(void);

/****************************************************************************/
/***        Exported Variables                                            ***/
/****************************************************************************/

/****************************************************************************/
/***        Local Variables                                               ***/
/****************************************************************************/
PRIVATE bool_t bStackReady = FALSE;

/****************************************************************************/
/***        Exported Functions                                            ***/
/****************************************************************************/
/****************************************************************************
 *
 * NAME: AppColdStart
 *
 * DESCRIPTION:
 * Entry point for application from boot loader. Initialises system.
 *
 * RETURNS:
 * Never returns.
 *
 ****************************************************************************/
PUBLIC void AppColdStart(void)
{
    /* Debug hooks: include these regardless of whether debugging or not */
    HAL_GDB_INIT();
    HAL_BREAKPOINT();

    /* General initialisation: reset hardware, set some values in PIB */
    JZS_sConfig.u32Channel = 0x11;
    JZS_sConfig.u16PanId = 0x1aab;
    /* JZS_sConfig.u16AppDataLength = 0; */

    /* set this field for 5139-based platforms. */
    /* JZS_sConfig.bFlashTypeIsSST = FALSE; */

    /* Enable UART 0: 19200-8-N-1 */
    vAHI_UartEnable(E_AHI_UART_0);
    vAHI_UartReset(E_AHI_UART_0, TRUE, TRUE);
    vAHI_UartReset(E_AHI_UART_0, FALSE, FALSE);
    vAHI_UartSetClockDivisor(E_AHI_UART_0, E_AHI_UART_RATE_19200);

    /* General initialisation */
    NullDeviceInit();

    /* No return from the above function call */
}

/****************************************************************************
 *
 * NAME: AppWarmStart
 *
 * DESCRIPTION:
 * Entry point for application from boot loader. Simply jumps to AppColdStart
 * as, in this instance, application will never warm start.
 *
 * RETURNS:
 * Never returns.
 *
 ****************************************************************************/
PUBLIC void AppWarmStart(void)
{
    AppColdStart();
}

/****************************************************************************
 *
 * NAME: JZA_boAppStart
 *
 * DESCRIPTION:
 * Would be used for instance to add simple descriptors for endpoints prior
 * starting as a coordinator/router/end device as defined in the make file
 *
 * RETURNS:
 *
 *
 ****************************************************************************/
bool_t JZA_boAppStart(void)
{
    JZS_vStartStack();
    return TRUE;
}

/****************************************************************************
 *
 * NAME: JZA_vAppEventHandler
 *
 * DESCRIPTION:
 * Main user routine. This is called by the Basic Operating System (BOS)
 * at regular intervals.
 *
 * RETURNS:
 *
 *
 ****************************************************************************/
void JZA_vAppEventHandler(void)
{
	if (bStackReady != TRUE)
	{
		return;
	}

	/* indicate network successfully started/joined by turning LED 1 off */
	vLedControl(0, FALSE);
}

/****************************************************************************
 *
 * NAME: JZA_vPeripheralEvent
 *
 * DESCRIPTION:
 * Adds events to the hardware event queue.
 *
 * PARAMETERS:      Name            RW  Usage
 *                  u32Device       R   Peripheral responsible for interrupt e.g DIO
 *					u32ItemBitmap	R   Source of interrupt e.g. DIO bit map
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void JZA_vPeripheralEvent(uint32 u32Device, uint32 u32ItemBitmap)
{
}

/****************************************************************************
 *
 * NAME: JZA_vAppDefineTasks
 *
 * DESCRIPTION:
 * Can be used to add additional tasks.
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void JZA_vAppDefineTasks(void)
{
}

/****************************************************************************
 *
 * NAME: JZA_eAfKvpObject
 *
 * DESCRIPTION:
 * Receives incoming KVP data frames
 *
 * PARAMETERS:      Name            	RW  Usage
 *                  eAddrMode			R   Address mode of incoming frame
 *					u16AddrSrc			R	Network address of source node
 *					u8SrcEP				R 	Endpoint address of source node
 *					u8LQI				R   Link Quality Indication
 *					u8DstEP				R	Destination endpoint address
 *					u8ClusterId			R	Cluster ID of incoming frame
 *					*pu8ClusterIDRsp	R	Pointer to cluster ID of response frame
 *					*puTransactionInd	R	Pointer to incoming frame
 *					*puTransactionRsp	R	Pointer to response frame
 *
 * RETURNS:
 * TRUE for stack to automatically generate KVP response frames when appropriate
 * FALSE otherwise
 *
 ****************************************************************************/
PUBLIC bool_t JZA_bAfKvpObject(	APS_Addrmode_e			eAddrMode,
								uint16					u16AddrSrc,
								uint8					u8SrcEP,
								uint8					u8LQI,
								uint8					u8DstEP,
								uint8					u8ClusterId,
								uint8					*pu8ClusterIDRsp,
								AF_Transaction_s		*puTransactionInd,
								AF_Transaction_s		*puTransactionRsp)
{

    return FALSE;
}

/****************************************************************************
 *
 * NAME: JZA_vAfKvpResponse
 *
 * DESCRIPTION:
 * Used to send response to incoming KVP frame
 *
 * PARAMETERS:      Name            	RW  Usage
 *                  eAddrMode			R   Address mode of incoming frame
 *					u16AddrSrc			R	Network address of source node
 *					u8SrcEP				R 	Endpoint address of source node
 *					u8LQI				R   Link Quality Indication
 *					u8DstEP				R	Destination endpoint address
 *					u8ClusterId			R	Cluster ID of incoming frame
 *					*puTransactionInd	R	Pointer to incoming frame
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void JZA_vAfKvpResponse(APS_Addrmode_e			eAddrMode,
								uint16					u16AddrSrc,
								uint8					u8SrcEP,
								uint8					u8LQI,
								uint8					u8DstEP,
								uint8					u8ClusterID,
								AF_Transaction_s		*puTransactionInd)
{
}

/****************************************************************************
 *
 * NAME: JZA_pu8AfMsgObject
 *
 * DESCRIPTION:
 * Receives incoming MSG data frames.
 *
 * PARAMETERS:      Name            		RW  Usage
 *                  eAddrMode			R   Address mode of incoming frame
 *					u16AddrSrc			R	Network address of source node
 *					u8SrcEP				R 	Endpoint address of source node
 *					u8LQI				R   Link Quality Indication
 *					u8DstEP				R	Destination endpoint address
 *					u8ClusterId			R	Cluster ID of incoming frame
 *					*pu8ClusterIDRsp	R	Pointer to cluster ID of response frame
 *					*puTransactionInd	R	Pointer to incoming frame
 *					*puTransactionRsp	R	Pointer to response frame
 * RETURNS:
 * FALSE
 *
 ****************************************************************************/
PUBLIC bool_t JZA_bAfMsgObject(APS_Addrmode_e		eAddrMode,
								uint16				u16AddrSrc,
								uint8				u8SrcEP,
								uint8				u8LQI,
								uint8 				u8DstEP,
								uint8				u8ClusterID,
								uint8 				*pu8ClusterIDRsp,
								AF_Transaction_s	*puTransactionInd,
								AF_Transaction_s	*puTransactionRsp)
{
    return FALSE;
}

/****************************************************************************
 *
 * NAME: JZA_vZdpResponse
 *
 * DESCRIPTION:
 * Receives responses to Binding or MatchDescriptor requests
 *
 * PARAMETERS:      Name            		RW  Usage
 * 					u8Type					R	Type of response
 *					u8LQI					R   Link Quality Indication
 *					*pu8Payload				R	Pointer to response
 *					u8PayloadLen			R	Length of response
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void JZA_vZdpResponse(uint8 u8Type, uint8 u8Lqi, uint8 *pu8Payload,
								uint8 u8PayloadLen)
{

}

/****************************************************************************
 *
 * NAME: JZA_vStackEvent
 *
 * DESCRIPTION:
 * Used to receive additional stack events such as Data Request confirm
 *
 * PARAMETERS:      Name            		RW  Usage
 *					eEventId				R	ID number of stack event
 *					*puStackEvent			R	Pointer to union containing
 *												stack event data
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void JZA_vStackEvent(teJZS_EventIdentifier 	eEventId,
                            tuJZS_StackEvent 		*puStackEvent)
{
	if (	(eEventId == JZS_EVENT_NWK_STARTED)
		||	(eEventId == JZS_EVENT_NWK_JOINED_AS_ROUTER))
    {
        bStackReady = TRUE;
    }
}

/****************************************************************************/
/***        Local Functions                                               ***/
/****************************************************************************/
/****************************************************************************
 *
 * NAME: NullDeviceInit
 *
 * DESCRIPTION:
 * Initialises stack and hardware.
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void NullDeviceInit(void)
{
    (void)JZS_u32InitSystem(TRUE);

    /* Set LED IO's to outputs */
	vLedInitRfd();
	vLedControl(0, TRUE);
	vLedControl(1, FALSE);

    /* Start BOS */
	(void)bBosRun(TRUE);
}

/****************************************************************************/
/***        END OF FILE                                                   ***/
/****************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -