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

📄 zkbcoordinator.c

📁 该代码为Jennic公司芯片JN5121
💻 C
📖 第 1 页 / 共 2 页
字号:
 ****************************************************************************/
PUBLIC void JZA_vPeripheralEvent(uint32 u32Device, uint32 u32ItemBitmap)
{
	/* Handles events from the harware API, places them on the hardware interrupt queue*/

    tsHwIntData *psHwIntData;
    uint8        u8WriteNextPtr;

    /* Queue event for processing during JZA_vAppEventHandler() call */
    u8WriteNextPtr = (sKbdDemoStat.sQueue.u8WritePtr + 1) & HW_INT_Q_PTR_MASK;

    if (u8WriteNextPtr != sKbdDemoStat.sQueue.u8ReadPtr)
    {
        /* There is space on queue */
        psHwIntData = &sKbdDemoStat.sQueue.asHwIntData[sKbdDemoStat.sQueue.u8WritePtr];
        psHwIntData->u32Device     = u32Device;
        psHwIntData->u32ItemBitmap = u32ItemBitmap;

        sKbdDemoStat.sQueue.u8WritePtr = u8WriteNextPtr;
    }

    /* If no space on queue, interrupt is silently discarded */
}

/****************************************************************************
 *
 * NAME: JZA_vAppDefineTasks
 *
 * DESCRIPTION:
 * Called by Zigbee stack during initialisation to allow the application to
 * initialise any tasks that it requires. This application requires none.
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PUBLIC void JZA_vAppDefineTasks(void)
{
}

/****************************************************************************/
/***        Local Functions                                               ***/
/****************************************************************************/
/****************************************************************************
 *
 * NAME: vInitKeyboardDemo
 *
 * DESCRIPTION:
 * Initialises ZigBee stack, evaluator board peripherals and wireless
 * keyboard software.
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vInitKeyboardDemo(void)
{
    /* Initialise Zigbee stack */
    (void) JZS_u32InitSystem();

    /* Calibrate 32kHz clock wakeup timer */
    sKbdDemoStat.sSystem.u32CalibOffset = 10000 / u32AHI_WakeTimerCalibrate();

    /* Evaluator boards LEDs - only one application LED used for Caps Lock status */
    vLedControl(LED_COORD_CAPS,     FALSE);
    vLedControl(LED_COORD_UNUSED_1, FALSE);
    vLedControl(LED_COORD_UNUSED_2, FALSE);
    vLedControl(LED_COORD_UNUSED_3, FALSE);

	/* Setup the LED's DIO pins */
    vLedInitFfd();

    /* Set up LCD and show the Jennic logo screen */
	vZKBlcdInit();

	/* init hardware queue pointers - although not used in this demo application */
    sKbdDemoStat.sQueue.u8ReadPtr  = 0;
    sKbdDemoStat.sQueue.u8WritePtr = 0;

    /* Receive packet sequence counter, for application level sequence control */
    sKbdDemoStat.sAppl.u8RxSeqNum  = 0;

    /* Start BOS */
    BOSRun();
}

/****************************************************************************
 *
 * NAME: JZA_eAfKvpObject
 *
 * DESCRIPTION:
 * Called when a KVP transaction has been received with a matching endpoint.
 *
 * Direct binding is used for this point-to-point keyboard demo, as would
 * be consistant with a pre-configured network (which a wireless keyboard is
 * likely to be).
 *
 * Any KVP object received is validated as being from a wireless keyboard
 * and then displayed on the coordinator's LCD as an ASCII code.
 *
 * PARAMETERS:      Name           RW  Usage
 *                  afSrcAddr      R   Address of sender device
 *                  u8DstEndpoint  R   Endpoint at receiver
 *                  pu8ClusterId   R   Pointer to cluster ID
 *                  eCommandTypeId R   KVP command type
 *                  u16AttributeId R   KVP attribute ID
 *                  pu8AfduLength  R   Pointer to length of data
 *                  pu8Afdu        R   Data array
 *
 * RETURNS:
 * AF_ERROR_CODE
 *
 ****************************************************************************/
AF_ERROR_CODE JZA_eAfKvpObject(AF_ADDRTYPE         afSrcAddr,
                               uint8               u8DstEndpoint,
                               uint8               u8SequenceNum,
                               uint8              *pu8ClusterId,
                               AF_COMMAND_TYPE_ID  eCommandTypeId,
                               uint16              u16AttributeId,
                               uint8              *pu8AfduLength,
                               uint8              *pu8Afdu)
{
	uint8 u8Key;

	/*  validate the message parameters to ensure it is for this endpoint */
    if ((afSrcAddr.hAddrMode != DEV_16BIT_ADDR) || (u8DstEndpoint != WKB_ENDPOINT_LCD))
    {
        return KVP_INVALID_ENDPOINT;
    }

    if ((eCommandTypeId != SET) && (eCommandTypeId != SET_ACKNOWLEDGMENT))
    {
        return KVP_INVALID_COMMAND_TYPE;
    }

	if (u16AttributeId != WKB_PS2_DISPLAY)
	{
		return KVP_UNSUPPORTED_ATTRIBUTE;
	}

	/* message is valid, check application sequence numbering */
	if (*pu8Afdu == sKbdDemoStat.sAppl.u8RxSeqNum)
	{
		/* new packet, convert from PS2 sequence to ASCII code */
		u8Key = u8PS2protocol(*(pu8Afdu+1));
		if (u8Key)
		{
			/* printable ASCII code, so send to LCD */
			vZKBlcdOutc(u8Key);
		}

		sKbdDemoStat.sAppl.u8RxSeqNum++; /* next packet number expected */
	}

    return KVP_SUCCESS;
}


/****************************************************************************
 *
 * NAME: JZA_vAfKvpResponse
 *
 * DESCRIPTION:
 * Called after a KVP transaction with acknowledgement request, when the
 * acknowledgement arrives.
 *
 * Not used in this demo application.
 *
 * PARAMETERS:      Name                   R/W Usage
 *                  srcAddressMod          R   Address of sender device
 *                  transactionSequenceNum R   KVP transaction number
 *                  commandTypeIdentifier  R   KVP command type
 *                  dstEndPoint            R   Endpoint at receiver
 *                  clusterID              R   Cluster ID
 *                  attributeIdentifier    R   KVP attribute ID
 *                  errorCode              R   Result code
 *                  afduLength             R   Length of payload data
 *                  pAfdu                  R   Payload data array
 *
 ****************************************************************************/
PUBLIC void JZA_vAfKvpResponse(AF_ADDRTYPE         srcAddressMod,
                               UINT8               transactionSequenceNum,
                               AF_COMMAND_TYPE_ID  commandTypeIdentifier,
                               UINT8               dstEndPoint,
                               UINT8               clusterID,
                               UINT16              attributeIdentifier,
                               UINT8               errorCode,
                               UINT8               afduLength,
                               UINT8              *pAfdu )
{
}

/****************************************************************************
 *
 * NAME: JZA_pu8AfMsgObject
 *
 * DESCRIPTION:
 * Called when a MSG transaction has been received with a matching endpoint.
 * Not usd in this demo application.
 *
 * PARAMETERS:      Name           RW  Usage
 *                  afSrcAddr      R   Address of sender device
 *                  dstEndPoint    R   Endpoint at receiver
 *                  clusterID      R   Pointer to cluster ID
 *                  afduLength     R   Pointer to length of data
 *                  pAfdu          R   Data array
 *
 * RETURNS:
 * NULL
 *
 ****************************************************************************/
PUBLIC UINT8 *JZA_pu8AfMsgObject(AF_ADDRTYPE afSrcAddr,
                                 UINT8       dstEndPoint,
                                 UINT8      *clusterID,
                                 UINT8      *afduLength,
                                 UINT8      *pAfdu)
{
    return NULL;
}

/****************************************************************************
 *
 * NAME: JZA_vZdpResponse
 *
 * DESCRIPTION:
 * Called when a ZDP response frame has been received. In this case no action
 * is taken as no ZDP responses are anticipated.
 *
 * PARAMETERS:      Name           RW  Usage
 *                  u8Type         R   ZDP response type
 *                  pu8Payload     R   Payload buffer
 *                  u8PayloadLen   R   Length of payload
 *
 ****************************************************************************/
PUBLIC void JZA_vZdpResponse(uint8 u8Type, 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)
{
}

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

⌨️ 快捷键说明

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